Class: Lifesaver::Notification::NotifiableAssociations

Inherits:
Object
  • Object
show all
Defined in:
lib/lifesaver/notification/notifiable_associations.rb

Defined Under Namespace

Classes: AssociationKeys

Instance Method Summary collapse

Constructor Details

#initializeNotifiableAssociations

Returns a new instance of NotifiableAssociations.



6
7
8
# File 'lib/lifesaver/notification/notifiable_associations.rb', line 6

def initialize
  @association_keys = AssociationKeys.new([], [])
end

Instance Method Details

#any_to_notify?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/lifesaver/notification/notifiable_associations.rb', line 32

def any_to_notify?
  !on_notify.empty?
end

#on_changeObject



28
29
30
# File 'lib/lifesaver/notification/notifiable_associations.rb', line 28

def on_change
  association_keys.on_change
end

#on_notifyObject



24
25
26
# File 'lib/lifesaver/notification/notifiable_associations.rb', line 24

def on_notify
  association_keys.on_notify
end

#populate(associations, options = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# 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