module Moneta::Utils

@api private

Public Instance Methods

only(hash, *keys) click to toggle source
# 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
to_int(value) click to toggle source
# File lib/moneta/utils.rb, line 22
def to_int(value)
  intvalue = value.to_i
  raise "#{value.inspect} is not an integer value" unless value == nil || intvalue.to_s == value.to_s
  intvalue
end
without(hash, *keys) click to toggle source
# 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