fix AS::OrderedOptions documentation [ci skip]
This commit is contained in:
parent
744b8e0f35
commit
c1c9f1c7b9
|
@ -1,20 +1,19 @@
|
||||||
# Usually key value pairs are handled something like this:
|
|
||||||
#
|
|
||||||
# h = {}
|
|
||||||
# h[:boy] = 'John'
|
|
||||||
# h[:girl] = 'Mary'
|
|
||||||
# h[:boy] # => 'John'
|
|
||||||
# h[:girl] # => 'Mary'
|
|
||||||
#
|
|
||||||
# Using <tt>OrderedOptions</tt>, the above code could be reduced to:
|
|
||||||
#
|
|
||||||
# h = ActiveSupport::OrderedOptions.new
|
|
||||||
# h.boy = 'John'
|
|
||||||
# h.girl = 'Mary'
|
|
||||||
# h.boy # => 'John'
|
|
||||||
# h.girl # => 'Mary'
|
|
||||||
#
|
|
||||||
module ActiveSupport #:nodoc:
|
module ActiveSupport #:nodoc:
|
||||||
|
# Usually key value pairs are handled something like this:
|
||||||
|
#
|
||||||
|
# h = {}
|
||||||
|
# h[:boy] = 'John'
|
||||||
|
# h[:girl] = 'Mary'
|
||||||
|
# h[:boy] # => 'John'
|
||||||
|
# h[:girl] # => 'Mary'
|
||||||
|
#
|
||||||
|
# Using <tt>OrderedOptions</tt>, the above code could be reduced to:
|
||||||
|
#
|
||||||
|
# h = ActiveSupport::OrderedOptions.new
|
||||||
|
# h.boy = 'John'
|
||||||
|
# h.girl = 'Mary'
|
||||||
|
# h.boy # => 'John'
|
||||||
|
# h.girl # => 'Mary'
|
||||||
class OrderedOptions < Hash
|
class OrderedOptions < Hash
|
||||||
alias_method :_get, :[] # preserve the original #[] method
|
alias_method :_get, :[] # preserve the original #[] method
|
||||||
protected :_get # make it protected
|
protected :_get # make it protected
|
||||||
|
|
Loading…
Reference in New Issue