Class: RFunk::Lazy
- Inherits:
-
Object
- Object
- RFunk::Lazy
- Defined in:
- lib/rfunk/lazy.rb
Instance Method Summary collapse
- #created? ⇒ Boolean
-
#initialize(lambda) ⇒ Lazy
constructor
A new instance of Lazy.
- #value ⇒ Object
Constructor Details
#initialize(lambda) ⇒ Lazy
Returns a new instance of Lazy.
3 4 5 6 |
# File 'lib/rfunk/lazy.rb', line 3 def initialize(lambda) @lambda = lambda @created = false end |
Instance Method Details
#created? ⇒ Boolean
12 13 14 |
# File 'lib/rfunk/lazy.rb', line 12 def created? created end |
#value ⇒ Object
8 9 10 |
# File 'lib/rfunk/lazy.rb', line 8 def value Option(@value ||= lambda.call.tap { self.created = true }) end |