Module: Ramazon::HashExcept

Defined in:
lib/ramazon/rails_additions.rb

Instance Method Summary collapse

Instance Method Details

#except(*keys) ⇒ Object

Returns a new hash without the given keys.



5
6
7
8
# File 'lib/ramazon/rails_additions.rb', line 5

def except(*keys)
  rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys)
  reject { |key,| rejected.include?(key) }
end

#except!(*keys) ⇒ Object

Replaces the hash without only the given keys.



11
12
13
# File 'lib/ramazon/rails_additions.rb', line 11

def except!(*keys)
  replace(except(*keys))
end