27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/promiscuous/publisher/model.rb', line 27
def hook_callbacks
klass.class_eval do
cattr_accessor :publisher_operation_hooked
return if self.publisher_operation_hooked
self.publisher_operation_hooked = true
[:create, :update, :destroy].each do |operation|
__send__("after_#{operation}", "promiscuous_publish_#{operation}".to_sym)
define_method "promiscuous_publish_#{operation}" do
self.class.promiscuous_publisher.new(:instance => self, :operation => operation).amqp_publish
end
end
end
end
|