Class: Fusion::FileThunk
- Inherits:
-
Object
- Object
- Fusion::FileThunk
- Defined in:
- lib/fusion.rb
Overview
Lazy, memoized reference to a file’s value (a “thunk” / promise).
Instance Method Summary collapse
- #force ⇒ Object
-
#initialize(loader, abspath) ⇒ FileThunk
constructor
A new instance of FileThunk.
Constructor Details
#initialize(loader, abspath) ⇒ FileThunk
Returns a new instance of FileThunk.
556 557 558 559 560 561 |
# File 'lib/fusion.rb', line 556 def initialize(loader, abspath) @loader = loader @abspath = abspath @state = :unforced # :unforced | :forcing | :done @value = nil end |
Instance Method Details
#force ⇒ Object
563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'lib/fusion.rb', line 563 def force case @state when :done then @value when :forcing # We are already evaluating this file and were asked for it again # without any intervening function boundary => non-productive data cycle. Fusion.mkerr({"kind" => "data_cycle", "path" => @abspath}) else @state = :forcing @value = @loader.evaluate_file(@abspath) @state = :done @value end end |