class GovFakeNotify::FetchAllMessagesStatusCommand

A service used to fetch all message statuses

Attributes

errors[R]
messages[R]
params[R]
store[R]

Public Class Methods

call(params, **kwargs) click to toggle source
# File lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb, line 14
def self.call(params, **kwargs)
  new(params, **kwargs).call
end
new(params, store: Store.instance) click to toggle source
# 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 = []
  @messages = []
end

Public Instance Methods

call() click to toggle source
# File lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb, line 25
def call
  message_keys = store.transaction { store.roots.select { |k| k =~ /^message-/ } }
  @messages = store.transaction { message_keys.map { |key| store.fetch(key) } }

  self
end
success?() click to toggle source
# File lib/gov_fake_notify/commands/fetch_all_messages_status_command.rb, line 32
def success?
  errors.empty?
end
to_json() click to toggle source
# 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: messages, links: [])
end