Class: Bade::Runtime::Block
Instance Attribute Summary collapse
- #block ⇒ Proc readonly
- #name ⇒ String readonly
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #call!(*args) ⇒ Object
-
#initialize(name, &block) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(name, &block) ⇒ Block
Returns a new instance of Block.
18 19 20 21 |
# File 'lib/bade/runtime/block.rb', line 18 def initialize(name, &block) @name = name @block = lambda &block unless block.nil? end |
Instance Attribute Details
#block ⇒ Proc (readonly)
10 11 12 |
# File 'lib/bade/runtime/block.rb', line 10 def block @block end |
Instance Method Details
#call(*args) ⇒ Object
23 24 25 |
# File 'lib/bade/runtime/block.rb', line 23 def call(*args) @block.call(*args) unless @block.nil? end |
#call!(*args) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/bade/runtime/block.rb', line 27 def call!(*args) if @block.nil? raise RuntimeError, "`#{@name}` must have block definition" else @block.call(*args) end end |