Class: Grape::Util::LazyBlock
- Inherits:
-
Object
- Object
- Grape::Util::LazyBlock
- Defined in:
- lib/grape/util/lazy_block.rb
Instance Method Summary collapse
- #evaluate ⇒ Object
- #evaluate_from(configuration) ⇒ Object
-
#initialize(&new_block) ⇒ LazyBlock
constructor
A new instance of LazyBlock.
- #lazy? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(&new_block) ⇒ LazyBlock
Returns a new instance of LazyBlock.
4 5 6 |
# File 'lib/grape/util/lazy_block.rb', line 4 def initialize(&new_block) @block = new_block end |
Instance Method Details
#evaluate ⇒ Object
12 13 14 |
# File 'lib/grape/util/lazy_block.rb', line 12 def evaluate @block.call({}) end |
#evaluate_from(configuration) ⇒ Object
8 9 10 |
# File 'lib/grape/util/lazy_block.rb', line 8 def evaluate_from(configuration) @block.call(configuration) end |
#lazy? ⇒ Boolean
16 17 18 |
# File 'lib/grape/util/lazy_block.rb', line 16 def lazy? true end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/grape/util/lazy_block.rb', line 20 def to_s evaluate.to_s end |