Sha256: 41f2e8f691064e26234b2eafe5e1f75c17fac991d83461353c1ffa446e13b39b

Contents?: true

Size: 428 Bytes

Versions: 22

Compression:

Stored size: 428 Bytes

Contents

module Trestle
  class Options < Hash
    def self.new(hash={})
      self[hash]
    end

    def merge(other, &block)
      dup.merge!(other, &block)
    end

    def merge!(other, &block)
      super(other || {}) do |key, v1, v2|
        if v1.is_a?(Hash) && v2.is_a?(Hash)
          v1.merge(v2, &block)
        elsif v1.is_a?(Array)
          v1 + Array(v2)
        else
          v2
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
trestle-0.10.1 lib/trestle/options.rb
trestle-0.10.0 lib/trestle/options.rb
trestle-0.10.0.pre2 lib/trestle/options.rb
trestle-0.10.0.pre lib/trestle/options.rb
trestle-0.9.8 lib/trestle/options.rb
trestle-0.9.7 lib/trestle/options.rb
trestle-0.9.6 lib/trestle/options.rb
trestle-0.9.5 lib/trestle/options.rb
trestle-0.9.4 lib/trestle/options.rb
trestle-0.9.3 lib/trestle/options.rb
trestle-0.9.2 lib/trestle/options.rb
trestle-0.9.1 lib/trestle/options.rb
trestle-0.9.0 lib/trestle/options.rb
trestle-0.8.13 lib/trestle/options.rb
trestle-0.8.12 lib/trestle/options.rb
trestle-0.8.11 lib/trestle/options.rb
trestle-0.8.10 lib/trestle/options.rb
trestle-0.8.9 lib/trestle/options.rb
trestle-0.8.8 lib/trestle/options.rb
trestle-0.8.7 lib/trestle/options.rb