aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/new_callbacks.rb21
1 files changed, 5 insertions, 16 deletions
diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb
index 237a285665..0fe3ee4bad 100644
--- a/activesupport/lib/active_support/new_callbacks.rb
+++ b/activesupport/lib/active_support/new_callbacks.rb
@@ -283,25 +283,14 @@ module ActiveSupport
filter.map {|f| _compile_filter(f)}
when Symbol
filter
+ when String
+ "(#{filter})"
when Proc
@klass.send(:define_method, method_name, &filter)
- method_name << case filter.arity
- when 1
- "(self)"
- when 2
- " self, Proc.new "
- else
- ""
- end
- when String
- @klass.class_eval <<-RUBY_EVAL
- def #{method_name}
- #{filter}
- end
- RUBY_EVAL
- method_name
+ return method_name if filter.arity == 0
+
+ method_name << (filter.arity == 1 ? "(self)" : " self, Proc.new ")
else
- kind = @kind
@klass.send(:define_method, "#{method_name}_object") { filter }
_normalize_legacy_filter(kind, filter)