Class: GovFakeNotify::FetchFileCommand
- Inherits:
-
Object
- Object
- GovFakeNotify::FetchFileCommand
- Defined in:
- lib/gov_fake_notify/commands/fetch_file_command.rb
Overview
A service used to fetch an attached file
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(id, attachment_store: AttachmentStore.instance) ⇒ FetchFileCommand
constructor
A new instance of FetchFileCommand.
- #success? ⇒ Boolean
Constructor Details
#initialize(id, attachment_store: AttachmentStore.instance) ⇒ FetchFileCommand
Returns a new instance of FetchFileCommand.
19 20 21 22 23 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 19 def initialize(id, attachment_store: AttachmentStore.instance) @id = id @attachment_store = @errors = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 13 def errors @errors end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
13 14 15 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 13 def filename @filename end |
Class Method Details
.call(id, **kwargs) ⇒ Object
15 16 17 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 15 def self.call(id, **kwargs) new(id, **kwargs).call end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 25 def call file_data = .fetch(id) errors << 'File not found' and return if file_data.nil? @filename = file_data['file'] self end |
#success? ⇒ Boolean
33 34 35 |
# File 'lib/gov_fake_notify/commands/fetch_file_command.rb', line 33 def success? errors.empty? end |