class ActiveSupport::OrderedOptions
:nodoc:
h.girl # => ‘Mary’
h.boy # => ‘John’
h.girl = ‘Mary’
h.boy = ‘John’
h = ActiveSupport::OrderedOptions.new
Using OrderedOptions, the above code could be reduced to:<br><br>h # => ‘Mary’<br>h # => ‘John’<br>h = ‘Mary’<br>h = ‘John’
h = {}
Usually key value pairs are handled something like this:
def [](key)
def [](key) super(key.to_sym) end
def []=(key, value)
def []=(key, value) super(key.to_sym, value) end
def method_missing(name, *args)
def method_missing(name, *args) if name.to_s =~ /(.*)=$/ self[$1] = args.first else self[name] end end
def respond_to?(name)
def respond_to?(name) true end