2005-12-15 15:03:23 -05:00
|
|
|
module ActiveSupport
|
|
|
|
class OptionMerger #:nodoc:
|
|
|
|
instance_methods.each do |method|
|
2006-09-27 14:46:46 -04:00
|
|
|
undef_method(method) if method !~ /^(__|instance_eval|class)/
|
2005-12-15 15:03:23 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(context, options)
|
|
|
|
@context, @options = context, options
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def method_missing(method, *arguments, &block)
|
|
|
|
merge_argument_options! arguments
|
|
|
|
@context.send(method, *arguments, &block)
|
|
|
|
end
|
|
|
|
|
|
|
|
def merge_argument_options!(arguments)
|
2006-04-26 17:49:41 -04:00
|
|
|
arguments << if arguments.last.respond_to? :to_hash
|
|
|
|
@options.merge(arguments.pop)
|
2005-12-15 15:03:23 -05:00
|
|
|
else
|
|
|
|
@options.dup
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|