~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activesupport/lib/active_support/option_merger.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
module ActiveSupport
2
 
  class OptionMerger #:nodoc:
3
 
    instance_methods.each do |method|
4
 
      undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
5
 
    end
6
 
 
7
 
    def initialize(context, options)
8
 
      @context, @options = context, options
9
 
    end
10
 
 
11
 
    private
12
 
      def method_missing(method, *arguments, &block)
13
 
        if arguments.last.is_a?(Proc)
14
 
          proc = arguments.pop
15
 
          arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) }
16
 
        else
17
 
          arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
18
 
        end
19
 
 
20
 
        @context.__send__(method, *arguments, &block)
21
 
      end
22
 
  end
23
 
end