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