Class: ApiEngineBase::InboxService::Message::Modify
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- ApiEngineBase::InboxService::Message::Modify
- Defined in:
- app/services/api_engine_base/inbox_service/message/modify.rb
Constant Summary collapse
- IS_ONE =
[ VIEWED = :viewed, DELETE = :delete, ]
Constants inherited from ServiceBase
ServiceBase::ON_ARGUMENT_VALIDATION
Instance Method Summary collapse
Methods inherited from ServiceBase
inherited, #internal_validate, #service_base_logging, #validate!
Methods included from ArgumentValidation
Methods included from ServiceLogging
#aletered_message, #class_name, #log, #log_error, #log_info, #log_prefix, #log_warn, #logger, #service_id
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/api_engine_base/inbox_service/message/modify.rb', line 17 def call = ::Message.where(user:, id: ids) if .empty? inline_argument_failure!(errors: { ids: "No ID's found for user" }) end case type when VIEWED modified_ids = .update(viewed: true).pluck(:id) when DELETE modified_ids = .destroy_all.pluck(:id) end context.modified = ApiEngineBase::Schema::Inbox::Modified.new( ids: modified_ids, type:, count: modified_ids.length, ) end |