2005-12-15 20:03:23 +00:00
|
|
|
module ActiveSupport
|
|
|
|
class OptionMerger #:nodoc:
|
2007-09-27 10:41:12 +00:00
|
|
|
instance_methods.each do |method|
|
2007-09-14 00:34:43 +00:00
|
|
|
undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
|
2005-12-15 20:03:23 +00:00
|
|
|
end
|
2007-09-27 10:41:12 +00:00
|
|
|
|
2005-12-15 20:03:23 +00:00
|
|
|
def initialize(context, options)
|
|
|
|
@context, @options = context, options
|
|
|
|
end
|
2007-09-27 10:41:12 +00:00
|
|
|
|
2005-12-15 20:03:23 +00:00
|
|
|
private
|
|
|
|
def method_missing(method, *arguments, &block)
|
2008-07-14 01:53:41 +00:00
|
|
|
arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup)
|
2008-08-31 20:15:26 +00:00
|
|
|
@context.__send__(method, *arguments, &block)
|
2005-12-15 20:03:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|