Class: IncidentManagement::TimelineEventTags::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- IncidentManagement::TimelineEventTags::CreateService
- Defined in:
- app/services/incident_management/timeline_event_tags/create_service.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, user, params) ⇒ CreateService
constructor
A new instance of CreateService.
Methods inherited from BaseService
#allowed?, #error, #error_in_save, #error_no_permissions, #success
Constructor Details
#initialize(project, user, params) ⇒ CreateService
Returns a new instance of CreateService.
8 9 10 11 12 |
# File 'app/services/incident_management/timeline_event_tags/create_service.rb', line 8 def initialize(project, user, params) @project = project @user = user @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'app/services/incident_management/timeline_event_tags/create_service.rb', line 6 def params @params end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
6 7 8 |
# File 'app/services/incident_management/timeline_event_tags/create_service.rb', line 6 def project @project end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'app/services/incident_management/timeline_event_tags/create_service.rb', line 6 def user @user end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/incident_management/timeline_event_tags/create_service.rb', line 14 def execute return unless allowed? timeline_event_tag_params = { project: project, name: params[:name] } timeline_event_tag = IncidentManagement::TimelineEventTag.new(timeline_event_tag_params) if timeline_event_tag.save success(timeline_event_tag) else error_in_save(timeline_event_tag) end end |