Class: Ribbon::Plugins::AroundStack::WrappedBlock

Inherits:
Object
  • Object
show all
Defined in:
lib/ribbon/plugins/around_stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ WrappedBlock

Returns a new instance of WrappedBlock


86
87
88
# File 'lib/ribbon/plugins/around_stack.rb', line 86

def initialize(&block)
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block


83
84
85
# File 'lib/ribbon/plugins/around_stack.rb', line 83

def block
  @block
end

#retvalObject (readonly)

Returns the value of attribute retval


84
85
86
# File 'lib/ribbon/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.

Raises:


96
97
98
99
100
101
102
# File 'lib/ribbon/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

Returns:

  • (Boolean)

90
91
92
# File 'lib/ribbon/plugins/around_stack.rb', line 90

def called?
  !!@_called
end