mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
fix AS/core_ext examples [ci skip]
This commit is contained in:
parent
794a70f944
commit
68a8a298d6
3 changed files with 3 additions and 3 deletions
|
@ -4,7 +4,7 @@ class Hash
|
|||
|
||||
# Returns an <tt>ActiveSupport::HashWithIndifferentAccess</tt> out of its receiver:
|
||||
#
|
||||
# { a: 1}.with_indifferent_access['a'] # => 1
|
||||
# { a: 1 }.with_indifferent_access['a'] # => 1
|
||||
def with_indifferent_access
|
||||
ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(self)
|
||||
end
|
||||
|
|
|
@ -63,7 +63,7 @@ class Hash
|
|||
#
|
||||
# { name: 'Rob', years: '28' }.assert_valid_keys(:name, :age) # => raises "ArgumentError: Unknown key: years"
|
||||
# { name: 'Rob', age: '28' }.assert_valid_keys('name', 'age') # => raises "ArgumentError: Unknown key: name"
|
||||
# { name: 'Rob', age: '28' }.assert_valid_keys(:name, :age) # => passes, raises nothing
|
||||
# { name: 'Rob', age: '28' }.assert_valid_keys(:name, :age) # => passes, raises nothing
|
||||
def assert_valid_keys(*valid_keys)
|
||||
valid_keys.flatten!
|
||||
each_key do |k|
|
||||
|
|
|
@ -5,7 +5,7 @@ class Hash
|
|||
#
|
||||
# is equivalent to
|
||||
#
|
||||
# options = { size: 25, velocity: 10}.merge(options)
|
||||
# options = { size: 25, velocity: 10 }.merge(options)
|
||||
#
|
||||
# This is particularly useful for initializing an options hash
|
||||
# with default values.
|
||||
|
|
Loading…
Reference in a new issue