Class: Ray::DSL::Handler
- Inherits:
-
Object
- Object
- Ray::DSL::Handler
- Defined in:
- lib/ray/dsl/handler.rb
Overview
Used internally to call blocks registered with Ray::DSL::EventListener#on.
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #call(event) ⇒ Object
-
#initialize(type, group, args, block) ⇒ Handler
constructor
A new instance of Handler.
- #match?(event) ⇒ Boolean (also: #===)
Constructor Details
#initialize(type, group, args, block) ⇒ Handler
Returns a new instance of Handler.
5 6 7 |
# File 'lib/ray/dsl/handler.rb', line 5 def initialize(type, group, args, block) @type, @group, @args, @block = type, group, args, block end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
27 28 29 |
# File 'lib/ray/dsl/handler.rb', line 27 def args @args end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
26 27 28 |
# File 'lib/ray/dsl/handler.rb', line 26 def group @group end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
25 26 27 |
# File 'lib/ray/dsl/handler.rb', line 25 def type @type end |
Instance Method Details
#call(event) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ray/dsl/handler.rb', line 17 def call(event) if @block.arity == 0 @block.call else @block.call(*event.args) end end |
#match?(event) ⇒ Boolean Also known as: ===
9 10 11 12 13 |
# File 'lib/ray/dsl/handler.rb', line 9 def match?(event) return false unless event.type == @type return match_args?(event.args) unless @args.empty? true end |