Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 4282

Show
Ignore:
Timestamp:
04/26/06 21:49:41 (2 years ago)
Author:
marcel
Message:

Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r4276 r4282  
    11*SVN* 
     2 
     3* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de]  
    24 
    35* Added Module#alias_method_chain [Jamis Buck] 
  • trunk/activesupport/lib/active_support/option_merger.rb

    r3314 r4282  
    1616       
    1717      def merge_argument_options!(arguments) 
    18         arguments << if arguments.last.respond_to? :merge! 
    19           arguments.pop.dup.merge!(@options
     18        arguments << if arguments.last.respond_to? :to_hash 
     19          @options.merge(arguments.pop
    2020        else 
    2121          @options.dup 
  • trunk/activesupport/test/option_merger_test.rb

    r3493 r4282  
    2828  end 
    2929 
     30  def test_method_with_options_allows_to_overwrite_options 
     31    local_options = {:hello => 'moon'} 
     32    assert_equal @options.keys, local_options.keys 
     33     
     34    with_options(@options) do |o| 
     35      assert_equal local_options, method_with_options(local_options) 
     36      assert_equal @options.merge(local_options),  
     37        o.method_with_options(local_options) 
     38      assert_equal local_options, o.method_with_options(local_options) 
     39    end 
     40    with_options(local_options) do |o| 
     41      assert_equal local_options.merge(@options), 
     42        o.method_with_options(@options) 
     43    end 
     44  end 
     45 
    3046  private 
    3147    def method_with_options(options = {})