module Shout::Observable

Attributes

shout_observer_list[RW]

Public Class Methods

included(mod) click to toggle source

Internal Methods

# File lib/shout/observable.rb, line 24
def self.included(mod)
  mod.send(:extend, ClassMethods)
end
run_callbacks(instance,event,*params) click to toggle source

Really this is for clarity until everyone is cool with the implementation.

# File lib/shout/observable.rb, line 8
def self.run_callbacks(instance,event,*params)
  instance.run_shout_callbacks(event,*params)
end

Public Instance Methods

idemp_observer(k,i) click to toggle source

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.

# 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) click to toggle source
# 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) click to toggle source
# 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