Add documentation to HashWithIndifferentAccess#except
https://api.rubyonrails.org/classes/ActiveSupport/HashWithIndifferentAccess.html#method-i-except Currently HashWithIndifferentAccess#except has no documentation. Since it's behavior is different from Hash#except, so it deserves its own documentation.
This commit is contained in:
parent
a8a1afd455
commit
8a56380c53
|
@ -295,6 +295,10 @@ module ActiveSupport
|
|||
super(convert_key(key))
|
||||
end
|
||||
|
||||
# Returns a hash with indifferent access that includes everything except given keys.
|
||||
# hash = { a: "x", b: "y", c: 10 }.with_indifferent_access
|
||||
# hash.except(:a, "b") # => {c: 10}.with_indifferent_access
|
||||
# hash # => { a: "x", b: "y", c: 10 }.with_indifferent_access
|
||||
def except(*keys)
|
||||
slice(*self.keys - keys.map { |key| convert_key(key) })
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue