Class: Syndi::Events::Listener
- Inherits:
-
Object
- Object
- Syndi::Events::Listener
- Defined in:
- lib/syndi/events.rb
Overview
A class which represents a listener.
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
-
#call(*args) ⇒ Object
Execute this listener.
-
#deaf ⇒ Object
Terminate this object.
-
#initialize(sys, event, priority, prc) ⇒ Listener
constructor
Spawn a new listener object.
- #inspect ⇒ Object (also: #to_s)
Constructor Details
#initialize(sys, event, priority, prc) ⇒ Listener
Spawn a new listener object.
100 101 102 103 104 105 106 107 |
# File 'lib/syndi/events.rb', line 100 def initialize sys, event, priority, prc @sys = sys @event = event @priority = priority @code = prc Syndi.log.verbose "new listener spawned and attached to #{event}: #{self}", VNOISY end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
97 98 99 |
# File 'lib/syndi/events.rb', line 97 def code @code end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
97 98 99 |
# File 'lib/syndi/events.rb', line 97 def event @event end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
97 98 99 |
# File 'lib/syndi/events.rb', line 97 def priority @priority end |
Instance Method Details
#call(*args) ⇒ Object
Execute this listener.
115 116 117 |
# File 'lib/syndi/events.rb', line 115 def call *args @code.call *args end |
#deaf ⇒ Object
Terminate this object.
110 111 112 |
# File 'lib/syndi/events.rb', line 110 def deaf @sys.events[event].delete self end |
#inspect ⇒ Object Also known as: to_s
119 120 121 |
# File 'lib/syndi/events.rb', line 119 def inspect "<#Syndi::Events::Listener: sys=#@sys event=#@event priority=#@priority>" end |