Class: GovFakeNotify::FetchMessageStatusCommand
- Inherits:
-
Object
- Object
- GovFakeNotify::FetchMessageStatusCommand
- Defined in:
- lib/gov_fake_notify/commands/fetch_message_status_command.rb
Overview
A service used to fetch a message status
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(id, store: Store.instance) ⇒ FetchMessageStatusCommand
constructor
A new instance of FetchMessageStatusCommand.
- #success? ⇒ Boolean
- #to_json ⇒ Object
Constructor Details
#initialize(id, store: Store.instance) ⇒ FetchMessageStatusCommand
Returns a new instance of FetchMessageStatusCommand.
18 19 20 21 22 23 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 18 def initialize(id, store: Store.instance) @id = id @store = store @errors = [] @message = nil end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 12 def errors @errors end |
Class Method Details
.call(id, **kwargs) ⇒ Object
14 15 16 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 14 def self.call(id, **kwargs) new(id, **kwargs).call end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 25 def call @message = store.transaction { store.fetch("message-#{id}") } errors << 'Message not found' and return if .nil? self end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 32 def success? errors.empty? end |
#to_json ⇒ Object
36 37 38 |
# File 'lib/gov_fake_notify/commands/fetch_message_status_command.rb', line 36 def to_json JSON.pretty_generate() end |