aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-06-11 10:20:29 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-06-11 10:20:29 -0700
commita63a964a5d1ed02cf0df1b1a33a96ed2a9fa987b (patch)
tree1eea1b0e20ba751aeaeacbddf3b57d16f63a4219 /activesupport/lib/active_support
parentebf2113a0565d2e38802f29291b3971b2c7f7922 (diff)
downloadrails-a63a964a5d1ed02cf0df1b1a33a96ed2a9fa987b.tar.gz
rails-a63a964a5d1ed02cf0df1b1a33a96ed2a9fa987b.tar.bz2
rails-a63a964a5d1ed02cf0df1b1a33a96ed2a9fa987b.zip
remove some evals from callback conditionals
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/callbacks.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 0cfbed5588..2cffa342ef 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -94,6 +94,15 @@ module ActiveSupport
def halted_callback_hook(filter)
end
+ module Conditionals # :nodoc:
+ class Value
+ def initialize(&block)
+ @block = block
+ end
+ def call(target, value); @block.call(value); end
+ end
+ end
+
module Filters
Environment = Struct.new(:target, :halted, :value, :run_block)
@@ -415,6 +424,7 @@ module ActiveSupport
when String
l = eval "lambda { |value| #{filter} }"
lambda { |target, value| target.instance_exec(value, &l) }
+ when Conditionals::Value then filter
when ::Proc
if filter.arity > 1
return lambda { |target, _, &block|