Class: GovFakeNotify::FetchAllMessagesStatusCommand
- Inherits:
-
Object
- Object
- GovFakeNotify::FetchAllMessagesStatusCommand
- Defined in:
- lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb
Overview
A service used to fetch all message statuses
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params, store: Store.instance) ⇒ FetchAllMessagesStatusCommand
constructor
A new instance of FetchAllMessagesStatusCommand.
- #success? ⇒ Boolean
- #to_json ⇒ Object
Constructor Details
#initialize(params, store: Store.instance) ⇒ FetchAllMessagesStatusCommand
Returns a new instance of FetchAllMessagesStatusCommand.
18 19 20 21 22 23 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 18 def initialize(params, store: Store.instance) @params = params @store = store @errors = [] = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 12 def errors @errors end |
Class Method Details
.call(params, **kwargs) ⇒ Object
14 15 16 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 14 def self.call(params, **kwargs) new(params, **kwargs).call end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 25 def call = store.transaction { store.roots.select { |k| k =~ /^message-/ } } = store.transaction { .map { |key| store.fetch(key) } } self end |
#success? ⇒ Boolean
32 33 34 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 32 def success? errors.empty? end |
#to_json ⇒ Object
36 37 38 39 |
# File 'lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb', line 36 def to_json # We do not support links yet JSON.pretty_generate(notifications: , links: []) end |