From 263abda3fd7ddfb826cd17ae88fb47d0e1d67fae Mon Sep 17 00:00:00 2001 From: Kirilll Zaitsev Date: Thu, 27 Aug 2015 02:58:49 +0300 Subject: Drone CI service --- lib/api/helpers.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lib/api/helpers.rb') 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) -- cgit v1.2.1