instance method
define_callbacks
Ruby on Rails 3.2.22.5
Since v3.0.20 Last seen in v3.2.22.5Signature
define_callbacks(klass)
No documentation comment.
Parameters
-
klassreq
Source
# File activerecord/lib/active_record/observer.rb, line 105
def define_callbacks(klass)
observer = self
observer_name = observer.class.name.underscore.gsub('/', '__')
ActiveRecord::Callbacks::CALLBACKS.each do |callback|
next unless respond_to?(callback)
callback_meth = :"_notify_#{observer_name}_for_#{callback}"
unless klass.respond_to?(callback_meth)
klass.send(:define_method, callback_meth) do |&block|
observer.update(callback, self, &block)
end
klass.send(callback, callback_meth)
end
end
end
Defined in activerecord/lib/active_record/observer.rb line 105
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Observer