class ActiveSupport::OrderedOptions - activesupport-4.2.3 Documentation

# class ActiveSupport::OrderedOptions

Usually key value pairs are handled something like this:

    h = {}
    h[:boy] = 'John'
    h[:girl] = 'Mary'
    h[:boy]  # => 'John'
    h[:girl] # => 'Mary'

Using `OrderedOptions`, the above code could be reduced to:

    h = ActiveSupport::OrderedOptions.new
    h.boy = 'John'
    h.girl = 'Mary'
    h.boy  # => 'John'
    h.girl # => 'Mary'

### Public Instance Methods

[](key) click to toggle source
Calls superclass method

    # File lib/active_support/ordered_options.rb, line 25
    def [](key)
      super(key.to_sym)
    end

Also aliased as: _get
[]=(key, value) click to toggle source
Calls superclass method

    # File lib/active_support/ordered_options.rb, line 21
    def []=(key, value)
      super(key.to_sym, value)
    end

_get(key)
Alias for: []
method_missing(name, *args) click to toggle source

    # File lib/active_support/ordered_options.rb, line 29
    def method_missing(name, *args)
      name_string = name.to_s
      if name_string.chomp!('=')
        self[name_string] = args.first
      else
        self[name]
      end
    end

respond_to_missing?(name, include_private) click to toggle source

    # File lib/active_support/ordered_options.rb, line 38
    def respond_to_missing?(name, include_private)
      true
    end