Sha256: b31477b4112d1bc0b2a17bee9d613131853e1dacb282118c2ca573989a342f08

Contents?: true

Size: 747 Bytes

Versions: 5

Compression:

Stored size: 747 Bytes

Contents

module ActiveSupport
  class HashWithIndifferentAccess < Hash
    # Returns +true+ so that <tt>Array#extract_options!</tt> finds members of
    # this class.
    def extractable_options?
      true
    end

    def with_indifferent_access
      dup
    end

    def nested_under_indifferent_access
      self
    end

    def initialize(constructor = {})
      if constructor.respond_to?(:to_hash)
        super()
        update(constructor)
      else
        super(constructor)
      end
    end

    def self.new_from_hash_copying_default(hash)
      hash = hash.to_hash
      new(hash).tap do |new_hash|
        new_hash.default = hash.default
        new_hash.default_proc = hash.default_proc if hash.default_proc
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-activesupport-0.3.3 opal/active_support/hash_with_indifferent_access.rb
opal-activesupport-0.3.2 opal/active_support/hash_with_indifferent_access.rb
opal-activesupport-0.3.1 opal/active_support/hash_with_indifferent_access.rb
opal-activesupport-0.3.0 opal/active_support/hash_with_indifferent_access.rb
opal-activesupport-0.2.0 opal/active_support/hash_with_indifferent_access.rb