Class: LaMaquina::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/la_maquina/engine.rb

Class Method Summary collapse

Class Method Details

.install(*attrs) ⇒ Object



32
33
34
35
36
# File 'lib/la_maquina/engine.rb', line 32

def install(*attrs)
  attrs.each do |piston|
    self.pistons << piston
  end
end

.notify!(notified_class, id, notifier_class = "") ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/la_maquina/engine.rb', line 13

def notify!( notified_class, id, notifier_class = "" )
  pistons.each do |piston|
    begin
      # We can't thread this because Rails executes this code before the commit somehow. 
      # What. yeah. I don't know either.
      
      # Thread.new{
      piston.fire! notified_class, id, notifier_class
      # }.join
    rescue => e
      LaMaquina.error_notifier.notify(  e,
                                        misfiring_piston: piston,
                                        notified_class: notified_class,
                                        notified_id: id,
                                        notifier_class: notifier_class )
    end
  end
end