lib/active_support/callbacks.rb in activesupport-4.0.0.rc1 vs lib/active_support/callbacks.rb in activesupport-4.0.0.rc2
- old
+ new
@@ -131,17 +131,11 @@
def next_id
@@_callback_sequence += 1
end
def matches?(_kind, _filter)
- if @_is_object_filter
- _filter_matches = @filter.to_s.start_with?(_method_name_for_object_filter(_kind, _filter, false))
- else
- _filter_matches = (@filter == _filter)
- end
-
- @kind == _kind && _filter_matches
+ @kind == _kind && @filter == _filter
end
def duplicates?(other)
matches?(other.kind, other.filter)
end
@@ -240,20 +234,10 @@
end
@compiled_options = conditions.flatten.join(" && ")
end
- def _method_name_for_object_filter(kind, filter, append_next_id = true)
- class_name = filter.kind_of?(Class) ? filter.to_s : filter.class.to_s
- class_name.gsub!(/<|>|#/, '')
- class_name.gsub!(/\/|:/, "_")
-
- method_name = "_callback_#{kind}_#{class_name}"
- method_name << "_#{next_id}" if append_next_id
- method_name
- end
-
# Filters support:
#
# Arrays:: Used in conditions. This is used to specify
# multiple conditions. Used internally to
# merge conditions from skip_* filters.
@@ -271,12 +255,10 @@
# Procs:: define_method'ed into methods.
# Objects::
# a method is created that calls the before_foo method
# on the object.
def _compile_filter(filter)
- @_is_object_filter = false
-
case filter
when Array
filter.map {|f| _compile_filter(f)}
when Symbol
filter
@@ -287,11 +269,10 @@
@klass.send(:define_method, method_name, &filter)
return method_name if filter.arity <= 0
method_name << (filter.arity == 1 ? "(self)" : " self, Proc.new ")
else
- method_name = _method_name_for_object_filter(kind, filter)
- @_is_object_filter = true
+ method_name = "_callback_#{@kind}_#{next_id}"
@klass.send(:define_method, "#{method_name}_object") { filter }
_normalize_legacy_filter(kind, filter)
scopes = Array(chain.config[:scope])
method_to_call = scopes.map{ |s| s.is_a?(Symbol) ? send(s) : s }.join("_")