class GovFakeNotify::FetchMessageStatusCommand

A service used to fetch a message status

Attributes

errors[R]
id[R]
message[R]
store[R]

Public Class Methods

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

Public Instance Methods

call() click to toggle source
# 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 message.nil?

  self
end
success?() click to toggle source
# File lib/gov_fake_notify/commands/fetch_message_status_command.rb, line 32
def success?
  errors.empty?
end
to_json() click to toggle source
# File lib/gov_fake_notify/commands/fetch_message_status_command.rb, line 36
def to_json
  JSON.pretty_generate(message)
end