Class: Users::SavedReplies::CreateService
- Inherits:
-
Object
- Object
- Users::SavedReplies::CreateService
- Defined in:
- app/services/users/saved_replies/create_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(current_user:, name:, content:) ⇒ CreateService
constructor
A new instance of CreateService.
Constructor Details
#initialize(current_user:, name:, content:) ⇒ CreateService
Returns a new instance of CreateService.
6 7 8 9 10 |
# File 'app/services/users/saved_replies/create_service.rb', line 6 def initialize(current_user:, name:, content:) @current_user = current_user @name = name @content = content end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'app/services/users/saved_replies/create_service.rb', line 12 def execute saved_reply = saved_replies.build(name: name, content: content) if saved_reply.save ServiceResponse.success(payload: { saved_reply: saved_reply }) else ServiceResponse.error(message: saved_reply.errors.) end end |