Module: Moneta::Utils Private

Extended by:
Utils
Included in:
Utils
Defined in:
lib/moneta/utils.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#only(hash, *keys) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
# File 'lib/moneta/utils.rb', line 15

def only(hash, *keys)
  return hash if hash.empty?
  ret = {}
  keys.each { |k| ret[k] = hash[k] }
  ret
end

#without(hash, *keys) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
9
10
11
12
13
# File 'lib/moneta/utils.rb', line 6

def without(hash, *keys)
  return hash if hash.empty?
  if keys.any? { |k| hash.include?(k) }
    hash = hash.dup
    keys.each { |k| hash.delete(k) }
  end
  hash
end