diff --git a/activesupport/lib/active_support/option_merger.rb b/activesupport/lib/active_support/option_merger.rb index c77bca1..91563d3 100644 --- a/activesupport/lib/active_support/option_merger.rb +++ b/activesupport/lib/active_support/option_merger.rb @@ -10,7 +10,13 @@ module ActiveSupport private def method_missing(method, *arguments, &block) - arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup) + case(arguments.last) + when Proc + proc = arguments.pop + arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) } + else + arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup) + end @context.send!(method, *arguments, &block) end end diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb index 0d72314..f26d616 100644 --- a/activesupport/test/option_merger_test.rb +++ b/activesupport/test/option_merger_test.rb @@ -64,6 +64,14 @@ class OptionMergerTest < Test::Unit::TestCase end end end + + def test_nested_method_with_options_using_lamdba + local_lamdba = lambda { { :lambda => true } } + with_options(@options) do |o| + assert_equal @options.merge(local_lamdba.call), + o.method_with_options(local_lamdba).call + end + end # Needed when counting objects with the ObjectSpace def test_option_merger_class_method