Ordered Options
OrderedOptions inherits from Hash and provides dynamic accessor methods.
With a Hash, key-value pairs are typically managed like this:
h = {}
h[:boy] = 'John'
h[:girl] = 'Mary'
h[:boy]  # => 'John'
h[:girl] # => 'Mary'
h[:dog]  # => nil
Using OrderedOptions, the above code can be written as:
h = ActiveSupport::OrderedOptions.new
h.boy = 'John'
h.girl = 'Mary'
h.boy  # => 'John'
h.girl # => 'Mary'
h.dog  # => nil
To raise an exception when the value is blank, append a bang to the key name, like:
h.dog! # => raises KeyError: :dog is blank
Methods
Instance Public methods
[](key)
              Also aliased as: _get
            
          
          
          
          
            📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 41
    def [](key)
      super(key.to_sym)
    end[]=(key, value)
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 37
    def []=(key, value)
      super(key.to_sym, value)
    enddig(key, *identifiers)
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 45
    def dig(key, *identifiers)
      super(key.to_sym, *identifiers)
    endextractable_options?()
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 64
    def extractable_options?
      true
    endinspect()
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 68
    def inspect
      "#<#{self.class.name} #{super}>"
    endmethod_missing(method, *args)
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 49
    def method_missing(method, *args)
      if method.end_with?("=")
        self[method.name.chomp("=")] = args.first
      elsif method.end_with?("!")
        name_string = method.name.chomp("!")
        self[name_string].presence || raise(KeyError.new(":#{name_string} is blank"))
      else
        self[method.name]
      end
    endrespond_to_missing?(name, include_private)
📝 Source code
# File activesupport/lib/active_support/ordered_options.rb, line 60
    def respond_to_missing?(name, include_private)
      true
    end