Class: Plugs::Lazy
- Inherits:
-
Object
- Object
- Plugs::Lazy
- Defined in:
- lib/lazy.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(&block) ⇒ Lazy
constructor
A new instance of Lazy.
Constructor Details
#initialize(&block) ⇒ Lazy
Returns a new instance of Lazy.
9 10 11 |
# File 'lib/lazy.rb', line 9 def initialize(&block) @proc = block end |
Class Method Details
.unwrap(value) ⇒ Object
5 6 7 |
# File 'lib/lazy.rb', line 5 def self.unwrap(value) value.is_a?(self) ? value.call : value end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 |
# File 'lib/lazy.rb', line 13 def call return @call if defined?(@call) @call = @proc.call end |