Class: ActiveRecord::Base

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.acts_as_insque_crud(*args) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/insque.rb', line 117

def self.acts_as_insque_crud(*args)
  options = args.extract_options!
  excluded = (options[:exclude] || []).map(&:to_s)

  set_callback :commit, :after do
    action = [:create, :update, :destroy].map {|a| a if transaction_include_action?(a) }.compact.first
    params = self.serializable_hash(options).delete_if {|key| (['created_at', 'updated_at'] + excluded).include? key}
    Insque.broadcast :"#{self.class.to_s.underscore}_#{action}", params
  end
end

Instance Method Details

#send_later(method, *args) ⇒ Object



114
115
116
# File 'lib/insque.rb', line 114

def send_later(method, *args)
  Insque.broadcast :send_later, {:class => self.class.name, :id => id, :method => method, :args => args }, :self
end