Class: Trestle::Toolbar::Block
- Inherits:
-
Object
- Object
- Trestle::Toolbar::Block
- Defined in:
- lib/trestle/toolbar.rb
Overview
Wraps a toolbar block to provide evaluation within the context of a template and enumerator
Instance Method Summary collapse
- #evaluate(builder, template, enumerator, *args) ⇒ Object
-
#initialize(&block) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(&block) ⇒ Block
Returns a new instance of Block.
43 44 45 |
# File 'lib/trestle/toolbar.rb', line 43 def initialize(&block) @block = block end |
Instance Method Details
#evaluate(builder, template, enumerator, *args) ⇒ Object
47 48 49 50 51 |
# File 'lib/trestle/toolbar.rb', line 47 def evaluate(builder, template, enumerator, *args) context = Context.new(builder, enumerator, *args) result = template.capture { template.instance_exec(context, *args, &@block) } enumerator << [result] if result.present? end |