Module: Shout::Observable
- Defined in:
- lib/shout/observable.rb
Overview
include me
Instance Attribute Summary collapse
-
#shout_observer_list ⇒ Object
Returns the value of attribute shout_observer_list.
Class Method Summary collapse
-
.included(mod) ⇒ Object
Internal Methods.
-
.run_callbacks(instance, event, *params) ⇒ Object
Really this is for clarity until everyone is cool with the implementation.
Instance Method Summary collapse
-
#idemp_observer(k, i) ⇒ Object
This is done this way because I want to be able to #new these up at the time an event comes in, rather than using and after_initialize callback.
- #notify_shout_observers(event, *params) ⇒ Object
- #run_shout_callbacks(event, *params) ⇒ Object
Instance Attribute Details
#shout_observer_list ⇒ Object
Returns the value of attribute shout_observer_list.
28 29 30 |
# File 'lib/shout/observable.rb', line 28 def shout_observer_list @shout_observer_list end |
Class Method Details
.included(mod) ⇒ Object
Internal Methods
24 25 26 |
# File 'lib/shout/observable.rb', line 24 def self.included(mod) mod.send(:extend, ClassMethods) end |
.run_callbacks(instance, event, *params) ⇒ Object
Really this is for clarity until everyone is cool with the implementation.
8 9 10 |
# File 'lib/shout/observable.rb', line 8 def self.run_callbacks(instance,event,*params) instance.run_shout_callbacks(event,*params) end |
Instance Method Details
#idemp_observer(k, i) ⇒ Object
This is done this way because I want to be able to #new these up at the time an event comes in, rather than using and after_initialize callback.
33 34 35 36 37 |
# File 'lib/shout/observable.rb', line 33 def idemp_observer(k,i) self.shout_observer_list ||= [] return if self.shout_observer_list.assoc(k) self.shout_observer_list.push([i.class, i]) end |
#notify_shout_observers(event, *params) ⇒ Object
17 18 19 20 21 |
# File 'lib/shout/observable.rb', line 17 def notify_shout_observers(event, *params) self.shout_observer_list.each do |k,i| i.update_with_shout_event(event, *params) end end |
#run_shout_callbacks(event, *params) ⇒ Object
12 13 14 15 16 |
# File 'lib/shout/observable.rb', line 12 def run_shout_callbacks(event, *params) # HMMM: not sure how I feel self.class.load_observers(self) # about this. See #idemp_observer. self.notify_shout_observers(event, *params) end |