Class: RLM::Context
- Inherits:
-
Object
- Object
- RLM::Context
- Defined in:
- lib/rlm/context.rb
Constant Summary collapse
- SANDBOX_FILES_ROOT =
"/mnt/rlm/files"
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
Instance Method Summary collapse
- #file_for(handle) ⇒ Object
- #handle_for(file) ⇒ Object
-
#initialize(inputs: {}, files: []) ⇒ Context
constructor
A new instance of Context.
- #manifest ⇒ Object
Constructor Details
#initialize(inputs: {}, files: []) ⇒ Context
Returns a new instance of Context.
9 10 11 12 13 |
# File 'lib/rlm/context.rb', line 9 def initialize(inputs: {}, files: []) @inputs = inputs.dup.freeze @files = Array(files).dup.freeze @handles = build_handles(@files) end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/rlm/context.rb', line 7 def files @files end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
7 8 9 |
# File 'lib/rlm/context.rb', line 7 def inputs @inputs end |
Instance Method Details
#file_for(handle) ⇒ Object
31 32 33 |
# File 'lib/rlm/context.rb', line 31 def file_for(handle) @handles[handle] end |
#handle_for(file) ⇒ Object
35 36 37 |
# File 'lib/rlm/context.rb', line 35 def handle_for(file) @handles.key(file) end |
#manifest ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rlm/context.rb', line 15 def manifest { files: @files.map do |file| handle = handle_for(file) { handle: handle, filename: file.filename, content_type: file.content_type, size_bytes: file.size_bytes, sandbox_path: ::File.join(SANDBOX_FILES_ROOT, file.filename) } end, inputs: serializable_inputs } end |