Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/allpay/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#filter(args) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/allpay/core_ext/hash.rb', line 2

def filter args
  return nil if args.empty?

  if args.size == 1
    args[0] = args[0].to_s if args[0].is_a? Symbol
    self.select { |key| key.to_s.match(args.first) }
  else
    self.select { |key| args.include?(key) }
  end
end