Class: Bade::Runtime::Block
- Inherits:
-
Object
- Object
- Bade::Runtime::Block
- Defined in:
- lib/bade/runtime/block.rb
Direct Known Subclasses
Defined Under Namespace
Classes: MissingBlockDefinitionError
Instance Attribute Summary collapse
- #block ⇒ Proc readonly
- #name ⇒ String readonly
- #render_binding ⇒ RenderBinding readonly
Instance Method Summary collapse
-
#initialize(name, render_binding, &block) ⇒ Block
constructor
A new instance of Block.
-
#render(*args) ⇒ Object
— Rendering methods.
- #render!(*args) ⇒ Object
Constructor Details
#initialize(name, render_binding, &block) ⇒ Block
Returns a new instance of Block.
49 50 51 52 53 |
# File 'lib/bade/runtime/block.rb', line 49 def initialize(name, render_binding, &block) @name = name @render_binding = render_binding @block = block end |
Instance Attribute Details
#block ⇒ Proc (readonly)
35 36 37 |
# File 'lib/bade/runtime/block.rb', line 35 def block @block end |
#render_binding ⇒ RenderBinding (readonly)
43 44 45 |
# File 'lib/bade/runtime/block.rb', line 43 def render_binding @render_binding end |
Instance Method Details
#render(*args) ⇒ Object
— Rendering methods
69 70 71 72 73 74 75 |
# File 'lib/bade/runtime/block.rb', line 69 def render(*args) if @block.nil? '' else render!(*args) end end |
#render!(*args) ⇒ Object
77 78 79 80 81 |
# File 'lib/bade/runtime/block.rb', line 77 def render!(*args) raise MissingBlockDefinitionError.new(name, :render) if @block.nil? @block.call(*args).join end |