Class: Adhoq::Storage::OnTheFly
- Inherits:
-
Object
- Object
- Adhoq::Storage::OnTheFly
- Defined in:
- lib/adhoq/storage/on_the_fly.rb
Constant Summary collapse
- PREFIX =
'memory://adhoq-on-the-fly'
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#reports ⇒ Object
readonly
Returns the value of attribute reports.
Instance Method Summary collapse
- #direct_download? ⇒ Boolean
- #get(identifier) ⇒ Object
-
#initialize(id_base = Process.pid) ⇒ OnTheFly
constructor
A new instance of OnTheFly.
- #store(suffix = nil, seed = Time.now, &block) ⇒ Object
Constructor Details
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/adhoq/storage/on_the_fly.rb', line 6 def identifier @identifier end |
#reports ⇒ Object (readonly)
Returns the value of attribute reports.
6 7 8 |
# File 'lib/adhoq/storage/on_the_fly.rb', line 6 def reports @reports end |
Instance Method Details
#direct_download? ⇒ Boolean
19 20 21 |
# File 'lib/adhoq/storage/on_the_fly.rb', line 19 def direct_download? false end |
#get(identifier) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/adhoq/storage/on_the_fly.rb', line 23 def get(identifier) if item = @reports.delete(identifier) item.read.tap { item.close } else nil end end |
#store(suffix = nil, seed = Time.now, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/adhoq/storage/on_the_fly.rb', line 13 def store(suffix = nil, seed = Time.now, &block) Adhoq::Storage.with_new_identifier(suffix, seed) do |identifier| @reports[identifier] = yield.tap(&:rewind) end end |