Class: Plugins::AroundStack::WrappedBlock
- Inherits:
-
Object
- Object
- Plugins::AroundStack::WrappedBlock
- Defined in:
- lib/plugins/around_stack.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#retval ⇒ Object
readonly
Returns the value of attribute retval.
Instance Method Summary collapse
-
#call(call_stack, *args) ⇒ Object
Call the wrapped block, ignoring the scope and call_stack arguments.
- #called? ⇒ Boolean
-
#initialize(&block) ⇒ WrappedBlock
constructor
A new instance of WrappedBlock.
Constructor Details
#initialize(&block) ⇒ WrappedBlock
Returns a new instance of WrappedBlock.
86 87 88 |
# File 'lib/plugins/around_stack.rb', line 86 def initialize(&block) @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
83 84 85 |
# File 'lib/plugins/around_stack.rb', line 83 def block @block end |
#retval ⇒ Object (readonly)
Returns the value of attribute retval.
84 85 86 |
# File 'lib/plugins/around_stack.rb', line 84 def retval @retval end |
Instance Method Details
#call(call_stack, *args) ⇒ Object
Call the wrapped block, ignoring the scope and call_stack arguments.
96 97 98 99 100 101 102 |
# File 'lib/plugins/around_stack.rb', line 96 def call(call_stack, *args) raise Errors::Error, 'receiving non-empty call stack' unless call_stack.empty? block.call(*args).tap { |retval| @retval = retval @_called = true } end |
#called? ⇒ Boolean
90 91 92 |
# File 'lib/plugins/around_stack.rb', line 90 def called? !!@_called end |