Class: Jace::Handler Private
- Inherits:
-
Object
- Object
- Jace::Handler
- Defined in:
- lib/jace/handler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Handler that will be executed once an event has been triggerd
Handler will use the given method name or block to execute some code within the given context
Instance Attribute Summary collapse
- #block ⇒ Object readonly private
Instance Method Summary collapse
- #call(context) ⇒ Object private
-
#initialize(method_name = nil, &block) ⇒ Handler
constructor
private
A new instance of Handler.
- #to_proc ⇒ Object private
Constructor Details
#initialize(method_name) ⇒ Handler #initialize(block) ⇒ Handler #initialize(&block) ⇒ Handler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Handler.
20 21 22 23 24 25 26 27 28 |
# File 'lib/jace/handler.rb', line 20 def initialize(method_name = nil, &block) if block @block = block if block elsif method_name.is_a?(Proc) @block = method_name else @block = proc { send(method_name) } end end |
Instance Attribute Details
#block ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/jace/handler.rb', line 12 def block @block end |
Instance Method Details
#call(context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
30 31 32 |
# File 'lib/jace/handler.rb', line 30 def call(context) context.instance_eval(&block) end |
#to_proc ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 |
# File 'lib/jace/handler.rb', line 34 def to_proc handler = self proc { |context| handler.call(context) } end |