class ActiveSupport::OrderedHash - activesupport-4.2.4 Documentation

# class ActiveSupport::OrderedHash

`ActiveSupport::OrderedHash` implements a hash that preserves insertion order.

    oh = ActiveSupport::OrderedHash.new
    oh[:a] = 1
    oh[:b] = 2
    oh.keys # => [:a, :b], this order is guaranteed

Also, maps the `omap` feature for YAML files (See yaml.org/type/omap.html) to support ordered items when loading from yaml.

`ActiveSupport::OrderedHash` is namespaced to prevent conflicts with other implementations.

### Public Instance Methods

encode_with(coder) click to toggle source

    # File lib/active_support/ordered_hash.rb, line 27
    def encode_with(coder)
      coder.represent_seq '!omap', map { |k,v| { k => v } }
    end

extractable_options?() click to toggle source

Returns true to make sure that this hash is extractable via `Array#extract_options!`

    # File lib/active_support/ordered_hash.rb, line 44
    def extractable_options?
      true
    end

nested_under_indifferent_access() click to toggle source

    # File lib/active_support/ordered_hash.rb, line 39
    def nested_under_indifferent_access
      self
    end

reject(*args, &block) click to toggle source

    # File lib/active_support/ordered_hash.rb, line 35
    def reject(*args, &block)
      dup.tap { |hash| hash.reject!(*args, &block) }
    end

select(*args, &block) click to toggle source

    # File lib/active_support/ordered_hash.rb, line 31
    def select(*args, &block)
      dup.tap { |hash| hash.select!(*args, &block) }
    end

to_yaml_type() click to toggle source

    # File lib/active_support/ordered_hash.rb, line 23
    def to_yaml_type
      "!tag:yaml.org,2002:omap"
    end