app/utils/hash_utils.rb
def sub(h, *keys)
    keys.reduce({}) do |sub_hash, k|
      sub_hash[k] = h[k] if h.has_key?(k)
      sub_hash
    end
  end
# Select a subset of the hash h using given set of keys.
# Only include keys that are present in h.
#
# Usage:
#   sub({first: "First", last: "Last", age: 55}, :first, :age, :sex)
#   => {first: "First", age: 55}
Select a subset of the hash h using given set of keys.
Only include keys that are present in h.


Select a subset of the hash h using given set of keys . Only include keys that are present in h .
def sub(h, *keys)
    keys.reduce({}) do |sub_hash, k|
      sub_hash[k] = h[k] if h.has_key?(k)
      sub_hash
    end
  end
def sub ( h , * keys ) keys . reduce ( { } ) do | sub_hash , k | sub_hash [ k ] = h [ k ] if h . has_key? ( k ) sub_hash end end
Select a subset of the hash h using given set of keys.
Select a subset of the hash h using given set of keys .
h
keys