Class: Notes::QuickActionsService

Inherits:
BaseService show all
Defined in:
app/services/notes/quick_actions_service.rb

Instance Attribute Summary collapse

Attributes inherited from BaseService

#current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#clear_noteable_diffs_cache, #increment_usage_counter

Methods inherited from BaseService

#initialize

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

#can?

Constructor Details

This class inherits a constructor from BaseService

Instance Attribute Details

#interpret_serviceObject (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

.supported?(note) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'app/services/notes/quick_actions_service.rb', line 24

def self.supported?(note)
  return true if note.for_work_item?

  supported_noteables.include? note.noteable_type
end

.supported_noteablesObject



20
21
22
# File 'app/services/notes/quick_actions_service.rb', line 20

def self.supported_noteables
  SUPPORTED_NOTEABLES
end

Instance Method Details

#apply_updates(update_params, note) ⇒ Object

Applies updates extracted to note#noteable The update parameters are extracted on self#execute



44
45
46
47
48
49
50
51
52
53
54
# File 'app/services/notes/quick_actions_service.rb', line 44

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

  execute_update_service(note, update_params)
end

#execute(note, options = {}) ⇒ Object



34
35
36
37
38
39
40
# File 'app/services/notes/quick_actions_service.rb', line 34

def execute(note, options = {})
  return [note.note, {}] unless supported?(note)

  @interpret_service = QuickActions::InterpretService.new(project, current_user, options)

  interpret_service.execute(note.note, note.noteable)
end

#supported?(note) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/services/notes/quick_actions_service.rb', line 30

def supported?(note)
  self.class.supported?(note)
end