Sha256: db55dd50afac2ad57f8741ba445bf34da7ed31222a5f6d2ff71cc2732fda514d
Contents?: true
Size: 952 Bytes
Versions: 1
Compression:
Stored size: 952 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
i18n-0.2.0 | test/with_options.rb |