Class: RailsExecution::Files::Reader
- Inherits:
-
Object
- Object
- RailsExecution::Files::Reader
- Defined in:
- lib/rails_execution/files/reader.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#get_file(name) ⇒ Object
Return: the Tempfile instance.
-
#initialize(task) ⇒ Reader
constructor
A new instance of Reader.
Constructor Details
#initialize(task) ⇒ Reader
Returns a new instance of Reader.
11 12 13 14 |
# File 'lib/rails_execution/files/reader.rb', line 11 def initialize(task) @task = task @tempfile_by_name = {} end |
Instance Method Details
#call ⇒ Object
16 17 18 |
# File 'lib/rails_execution/files/reader.rb', line 16 def call raise ::NotImplementedError, "load_files (Output: { 'file1' => 'file-url', file2 => 'file-url' })" end |
#get_file(name) ⇒ Object
Return: the Tempfile instance
21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_execution/files/reader.rb', line 21 def get_file(name) return nil if name.blank? @file_url_by_name ||= call file_url = @file_url_by_name[name] return nil if file_url.blank? @tempfile_by_name[name] ||= save_to_tempfile(name, file_url) end |