YAGNI Method references. Deprecated

This commit is contained in:
Yehuda Katz 2009-06-02 22:06:21 -07:00
parent 6b4da2ecac
commit d6e4113c83
2 changed files with 11 additions and 16 deletions

@ -876,10 +876,12 @@ def test_with_instance
assert_raise(After) { test_process(controller,'raises_after') }
end
def test_with_method
controller = ControllerWithFilterMethod
assert_nothing_raised { test_process(controller,'no_raise') }
assert_raise(After) { test_process(controller,'raises_after') }
for_tag(:old_base) do
def test_with_method
controller = ControllerWithFilterMethod
assert_nothing_raised { test_process(controller,'no_raise') }
assert_raise(After) { test_process(controller,'raises_after') }
end
end
def test_with_proc

@ -180,9 +180,10 @@ def start(key = nil, options = {})
filter = <<-RUBY_EVAL
unless halted
result = #{@filter}
halted ||= (#{terminator})
halted = (#{terminator})
end
RUBY_EVAL
[@compiled_options[0], filter, @compiled_options[1]].compact.join("\n")
else
# Compile around filters with conditions into proxy methods
@ -201,7 +202,7 @@ def start(key = nil, options = {})
# end
name = "_conditional_callback_#{@kind}_#{next_id}"
txt = <<-RUBY_EVAL
txt, line = <<-RUBY_EVAL, __LINE__
def #{name}(halted)
#{@compiled_options[0] || "if true"} && !halted
#{@filter} do
@ -212,7 +213,7 @@ def #{name}(halted)
end
end
RUBY_EVAL
@klass.class_eval(txt)
@klass.class_eval(txt, __FILE__, line)
"#{name}(halted) do"
end
end
@ -291,15 +292,7 @@ def _compile_filter(filter)
" self, Proc.new "
else
""
end
when Method
@klass.send(:define_method, "#{method_name}_method") { filter }
@klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
def #{method_name}(&blk)
#{method_name}_method.call(self, &blk)
end
RUBY_EVAL
method_name
end
when String
@klass.class_eval <<-RUBY_EVAL
def #{method_name}