module State::Notifier
Constants
- VERSION
Public Instance Methods
notify_targets(event)
click to toggle source
# File lib/state/notifier.rb, line 7 def notify_targets(event) klass = self.class # support subclassing. search through parent chain for notification settings while klass && ! klass.notification_targets klass = klass.superclass end unless klass Rails.logger.debug "couldn't find notifier settings for #{self.class.name}" return end name = klass.name.underscore method = [name, event] * '_' targets = klass.notification_targets.map do |m| m.is_a?(Symbol) ? send(m) : m end.flatten Rails.logger.debug "StateNotifier: notifying #{method}, #{targets.size} targets" targets.each do |t| t.send(method, self) if t.respond_to?(method) end end
notify_transition(transition)
click to toggle source
# File lib/state/notifier.rb, line 34 def notify_transition(transition) notify_targets transition.event unless transition.to == transition.from notify_targets transition.to notify_targets "#{transition.from}_#{transition.event}" notify_targets "#{transition.event}_#{transition.to}" notify_targets "#{transition.from}_#{transition.to}" notify_targets "#{transition.from}_#{transition.event}_#{transition.to}" notify_targets :state_changed end end