Class: Metrics::UsersStarredDashboards::CreateService

Inherits:
BaseService
  • Object
show all
Includes:
Stepable
Defined in:
app/services/metrics/users_starred_dashboards/create_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params

Instance Method Summary collapse

Methods included from Stepable

#execute_steps, #steps

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

#initialize(user, project, dashboard_path) ⇒ CreateService

Returns a new instance of CreateService.


13
14
15
# File 'app/services/metrics/users_starred_dashboards/create_service.rb', line 13

def initialize(user, project, dashboard_path)
  @user, @project, @dashboard_path = user, project, dashboard_path
end

Instance Method Details

#executeObject


17
18
19
20
21
22
23
24
25
26
# File 'app/services/metrics/users_starred_dashboards/create_service.rb', line 17

def execute
  keys = %i[status message starred_dashboard]
  status, message, dashboards = execute_steps.values_at(*keys)

  if status != :success
    ServiceResponse.error(message: message)
  else
    ServiceResponse.success(payload: dashboards)
  end
end