aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorYehuda Katz <wycats@yehuda-katzs-macbookpro41.local>2009-06-02 22:16:52 -0700
committerMichael Koziarski <michael@koziarski.com>2009-06-09 19:47:53 +1200
commit8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a (patch)
tree40703c20c57954f7aa9e605a52b09656a407e20e /activesupport
parente9a6255938e5f860ab367a1a304409821398e36b (diff)
downloadrails-8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a.tar.gz
rails-8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a.tar.bz2
rails-8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a.zip
More pruning of NewCallbacks
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)