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
# File 'lib/la_maquina/notifier.rb', line 24

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

    object  = notified[:object]
    options = notified[:options]

    comm_object = options[:using]

    klass = notified_klass( object, options )
    id    = notified_id( object, options )

    notifier_class = LaMaquina.format_object_name(self)

    begin
      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
    rescue => e
      LaMaquina.error_notifier.notify(  e,
                                        notified_class: klass,
                                        notified_id: id,
                                        notifier_class: notifier_class,
                                        notifier_id: self.id)
    end
  end
end