Permalink
Browse files

More pruning of NewCallbacks

  • Loading branch information...
Yehuda Katz authored and NZKoz committed Jun 3, 2009
1 parent e9a6255 commit 8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a
Showing with 5 additions and 16 deletions.
  1. +5 −16 activesupport/lib/active_support/new_callbacks.rb
@@ -283,25 +283,14 @@ def _compile_filter(filter)
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)

0 comments on commit 8cae3cd

Please sign in to comment.