Module: LaMaquina::Notifier

Extended by:
ActiveSupport::Concern
Includes:
ActiveRecord::Callbacks
Defined in:
lib/la_maquina/notifier.rb

Instance Method Summary collapse

Instance Method Details

#notify!Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/la_maquina/notifier.rb', line 24

def notify!
  self.class.notified_objects.each do |notified|

    target  = notified[:target]
    options = notified[:options]

    comm_object = options[:using]

    klass = notified_class( target, options )
    ids   = notified_id( target, options )

    notifier_class = LaMaquina.format_object_name(self)

    begin
      ids.each do |id|
        if comm_object
          comm_object.notify(:notified_class => klass, :notified_id => id, :notifier_class => notifier_class)
        else
          LaMaquina::Engine.notify! klass, id, notifier_class
        end
      end
    rescue => e
      LaMaquina.error_notifier.notify(  e,
                                        notified_class: klass,
                                        notified_id: id,
                                        notifier_class: notifier_class,
                                        notifier_id: self.id)
    end
  end
end