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