Class: Riaction::CrudEventCallback

Inherits:
Object
  • Object
show all
Defined in:
lib/riaction/crud_event_callback.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_name) ⇒ CrudEventCallback

Returns a new instance of CrudEventCallback.



6
7
8
# File 'lib/riaction/crud_event_callback.rb', line 6

def initialize(event_name)
  @event_name = event_name
end

Instance Method Details

#after_create(record) ⇒ Object

Enqueues a Riaction::EventPerformer object in resque after a model has been created



11
12
13
14
15
# File 'lib/riaction/crud_event_callback.rb', line 11

def after_create(record)
  if record.riaction_log_event?(@event_name) && !record.class.riactionless?
    Resque.enqueue(::Riaction::EventPerformer, @event_name, record.class.base_class.to_s, record.id)
  end
end

#after_destroy(record) ⇒ Object

Enqueues a Riaction::EventPerformer object in resque after a model has been destroyed



25
26
27
28
29
# File 'lib/riaction/crud_event_callback.rb', line 25

def after_destroy(record)
  if record.riaction_log_event?(@event_name) && !record.class.riactionless?
    Resque.enqueue(::Riaction::EventPerformer, @event_name, record.class.base_class.to_s, record.id)
  end
end

#after_update(record) ⇒ Object

Enqueues a Riaction::EventPerformer object in resque after a model has been updated



18
19
20
21
22
# File 'lib/riaction/crud_event_callback.rb', line 18

def after_update(record)            
  if record.riaction_log_event?(@event_name) && !record.class.riactionless?
    Resque.enqueue(::Riaction::EventPerformer, @event_name, record.class.base_class.to_s, record.id)
  end
end