class GovFakeNotify::FetchFileCommand

A service used to fetch an attached file

Attributes

attachment_store[R]
errors[R]
filename[R]
id[R]

Public Class Methods

call(id, **kwargs) click to toggle source
# File lib/gov_fake_notify/commands/fetch_file_command.rb, line 15
def self.call(id, **kwargs)
  new(id, **kwargs).call
end
new(id, attachment_store: AttachmentStore.instance) click to toggle source
# File lib/gov_fake_notify/commands/fetch_file_command.rb, line 19
def initialize(id, attachment_store: AttachmentStore.instance)
  @id = id
  @attachment_store = attachment_store
  @errors = []
end

Public Instance Methods

call() click to toggle source
# File lib/gov_fake_notify/commands/fetch_file_command.rb, line 25
def call
  file_data = attachment_store.fetch(id)
  errors << 'File not found' and return if file_data.nil?

  @filename = file_data['file']
  self
end
success?() click to toggle source
# File lib/gov_fake_notify/commands/fetch_file_command.rb, line 33
def success?
  errors.empty?
end