class Lifesaver::Notification::NotifiableAssociations
Attributes
association_keys[RW]
Public Class Methods
new()
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 6 def initialize @association_keys = AssociationKeys.new([], []) end
Public Instance Methods
any_to_notify?()
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 32 def any_to_notify? !on_notify.empty? end
on_change()
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 28 def on_change association_keys.on_change end
on_notify()
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 24 def on_notify association_keys.on_notify end
populate(associations, options = nil)
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 10 def populate(associations, options = nil) options ||= {} add_associations(:on_change, associations) add_associations(:on_notify, associations) if options[:only_on_change] add_associations(:on_change, options[:only_on_change]) end if options[:only_on_notify] add_associations(:on_notify, options[:only_on_notify]) end end
Private Instance Methods
add_associations(key, associations)
click to toggle source
# File lib/lifesaver/notification/notifiable_associations.rb, line 40 def add_associations(key, associations) if associations.is_a?(Array) association_keys[key] |= associations else association_keys[key] << associations end end