Class: WebHooks::CreateService
- Inherits:
-
Object
- Object
- WebHooks::CreateService
- Includes:
- Services::ReturnServiceResponses
- Defined in:
- app/services/web_hooks/create_service.rb
Instance Method Summary collapse
- #execute(hook_params, relation) ⇒ Object
-
#initialize(current_user) ⇒ CreateService
constructor
A new instance of CreateService.
Methods included from Services::ReturnServiceResponses
Constructor Details
#initialize(current_user) ⇒ CreateService
Returns a new instance of CreateService.
7 8 9 |
# File 'app/services/web_hooks/create_service.rb', line 7 def initialize(current_user) @current_user = current_user end |
Instance Method Details
#execute(hook_params, relation) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/web_hooks/create_service.rb', line 11 def execute(hook_params, relation) hook = relation.new(hook_params) if hook.save after_create(hook) else return error("Invalid url given", 422) if hook.errors[:url].present? return error("Invalid branch filter given", 422) if hook.errors[:push_events_branch_filter].present? error(hook.errors..to_sentence, 422) end end |