Class: Shouter::Listener
- Inherits:
-
Object
- Object
- Shouter::Listener
- Defined in:
- lib/shouter/listener.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #for?(scope) ⇒ Boolean
-
#initialize(object, options) ⇒ Listener
constructor
A new instance of Listener.
- #notify(event, args, &block) ⇒ Object
Constructor Details
#initialize(object, options) ⇒ Listener
Returns a new instance of Listener.
12 13 14 15 16 17 |
# File 'lib/shouter/listener.rb', line 12 def initialize(object, ) raise Shouter::ScopeMissingError unless [:scope] @object = object @options = end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
10 11 12 |
# File 'lib/shouter/listener.rb', line 10 def object @object end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/shouter/listener.rb', line 10 def @options end |
Instance Method Details
#for?(scope) ⇒ Boolean
29 30 31 |
# File 'lib/shouter/listener.rb', line 29 def for?(scope) [:scope] == scope end |
#notify(event, args, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/shouter/listener.rb', line 19 def notify(event, args, &block) return unless object.respond_to?(event) if fire_guard! object.public_send(event, *args) fire_hook!(callback || block) Store.unregister(object) if single? end end |