Class: RFunk::Lazy

Inherits:
Object
  • Object
show all
Defined in:
lib/rfunk/lazy.rb

Instance Method Summary collapse

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

Returns:

  • (Boolean)


12
13
14
# File 'lib/rfunk/lazy.rb', line 12

def created?
  created
end

#valueObject



8
9
10
# File 'lib/rfunk/lazy.rb', line 8

def value
  Option(@value ||= lambda.call.tap { self.created = true  })
end