Permalink
Browse files

Make internal callback model definitions private in AMo

These _define class methods don't need to be exposed to objects that
extend ActiveModel::Callbacks.

Also use merge! options to avoid the creation of an extra hash.
  • Loading branch information...
1 parent 24a4cc7 commit 2a7cfee13e5eb4021a6e5a6ec986f495e7e8f73f @carlosantoniodasilva carlosantoniodasilva committed Jun 25, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 activemodel/lib/active_model/callbacks.rb
@@ -89,11 +89,11 @@ def self.extended(base) #:nodoc:
def define_model_callbacks(*callbacks)
options = callbacks.extract_options!
options = {
- :terminator => "result == false",
- :skip_after_callbacks_if_terminated => true,
- :scope => [:kind, :name],
- :only => [:before, :around, :after]
- }.merge(options)
+ :terminator => "result == false",
+ :skip_after_callbacks_if_terminated => true,
+ :scope => [:kind, :name],
+ :only => [:before, :around, :after]
+ }.merge!(options)
types = Array(options.delete(:only))
@@ -106,6 +106,8 @@ def define_model_callbacks(*callbacks)
end
end
+ private
+
def _define_before_model_callback(klass, callback) #:nodoc:
klass.class_eval <<-CALLBACK, __FILE__, __LINE__ + 1
def self.before_#{callback}(*args, &block)

0 comments on commit 2a7cfee

Please sign in to comment.