Sha256: 14c5a1a1fea7d37c47fd33def1b72f10f0ebe8609e6ef5729c073b69b4a354d3
Contents?: true
Size: 921 Bytes
Versions: 5
Compression:
Stored size: 921 Bytes
Contents
# this is only here so we can test I18n works nicely with ActiveSupports # with_options. Maybe we can just remove it? class Object def with_options(options) yield ActiveSupport::OptionMerger.new(self, options) end end module ActiveSupport class OptionMerger #:nodoc: instance_methods.each do |method| undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/ end def initialize(context, options) @context, @options = context, options end private def method_missing(method, *arguments, &block) if arguments.last.is_a?(Proc) proc = arguments.pop arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) } else arguments << (arguments.last.respond_to?(:to_hash) ? @options.deep_merge(arguments.pop) : @options.dup) end @context.__send__(method, *arguments, &block) end end end
Version data entries
5 entries across 5 versions & 3 rubygems