Class: Notes::QuickActionsService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Notes::QuickActionsService
- Defined in:
- app/services/notes/quick_actions_service.rb
Instance Attribute Summary collapse
-
#interpret_service ⇒ Object
readonly
Returns the value of attribute interpret_service.
Attributes inherited from BaseService
#current_user, #params, #project
Class Method Summary collapse
Instance Method Summary collapse
-
#apply_updates(update_params, note) ⇒ Object
Applies updates extracted to note#noteable The update parameters are extracted on self#execute.
- #execute(note, options = {}) ⇒ Object
- #supported?(note) ⇒ Boolean
Methods inherited from BaseService
#clear_noteable_diffs_cache, #increment_usage_counter
Methods inherited from BaseService
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
This class inherits a constructor from BaseService
Instance Attribute Details
#interpret_service ⇒ Object (readonly)
Returns the value of attribute interpret_service
12 13 14 |
# File 'app/services/notes/quick_actions_service.rb', line 12 def interpret_service @interpret_service end |
Class Method Details
.noteable_update_service(note) ⇒ Object
27 28 29 |
# File 'app/services/notes/quick_actions_service.rb', line 27 def self.noteable_update_service(note) update_services[note.noteable_type] end |
.supported?(note) ⇒ Boolean
31 32 33 |
# File 'app/services/notes/quick_actions_service.rb', line 31 def self.supported?(note) !!noteable_update_service(note) end |
.update_services ⇒ Object
23 24 25 |
# File 'app/services/notes/quick_actions_service.rb', line 23 def self.update_services UPDATE_SERVICES end |
Instance Method Details
#apply_updates(update_params, note) ⇒ Object
Applies updates extracted to note#noteable The update parameters are extracted on self#execute
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/notes/quick_actions_service.rb', line 49 def apply_updates(update_params, note) return if update_params.empty? return unless supported?(note) # We need the `id` after the note is persisted if update_params[:spend_time] update_params[:spend_time][:note_id] = note.id end self.class.noteable_update_service(note).new(note.resource_parent, current_user, update_params).execute(note.noteable) end |
#execute(note, options = {}) ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/services/notes/quick_actions_service.rb', line 39 def execute(note, = {}) return [note.note, {}] unless supported?(note) @interpret_service = QuickActions::InterpretService.new(project, current_user, ) interpret_service.execute(note.note, note.noteable) end |
#supported?(note) ⇒ Boolean
35 36 37 |
# File 'app/services/notes/quick_actions_service.rb', line 35 def supported?(note) self.class.supported?(note) end |