summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-09 14:56:02 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-09 14:56:02 +0200
commit0b5d627cd4a3f81934e7772e3558356c9dd2e3cf (patch)
treea232d232e543ef372d91d0dfffbc93985f37d982 /lib/api/helpers.rb
parent90c338a49541c95452181af9e0d0bcf9da6c51ad (diff)
parent0d610270d9634b783137bc6318eff4aa82572a7d (diff)
downloadgitlab-ce-0b5d627cd4a3f81934e7772e3558356c9dd2e3cf.tar.gz
Merge branch 'master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 1ebf9a1f022..76c9cc2e3a4 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -55,6 +55,32 @@ module API
end
end
+ def project_service
+ @project_service ||= begin
+ underscored_service = params[:service_slug].underscore
+
+ if Service.available_services_names.include?(underscored_service)
+ user_project.build_missing_services
+
+ service_method = "#{underscored_service}_service"
+
+ send_service(service_method)
+ end
+ end
+
+ @project_service || not_found!("Service")
+ end
+
+ def send_service(service_method)
+ user_project.send(service_method)
+ end
+
+ def service_attributes
+ @service_attributes ||= project_service.fields.inject([]) do |arr, hash|
+ arr << hash[:name].to_sym
+ end
+ end
+
def find_group(id)
begin
group = Group.find(id)