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.
6 7 8 |
# File 'lib/grape/util/lazy_block.rb', line 6 def initialize(&new_block) @block = new_block end |
Instance Method Details
#evaluate ⇒ Object
14 15 16 |
# File 'lib/grape/util/lazy_block.rb', line 14 def evaluate @block.call({}) end |
#evaluate_from(configuration) ⇒ Object
10 11 12 |
# File 'lib/grape/util/lazy_block.rb', line 10 def evaluate_from(configuration) @block.call(configuration) end |
#lazy? ⇒ Boolean
18 19 20 |
# File 'lib/grape/util/lazy_block.rb', line 18 def lazy? true end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/grape/util/lazy_block.rb', line 22 def to_s evaluate.to_s end |