Method: MediaTypes::Hash#slice

Defined in:
lib/media_types/hash.rb

#slice(*keep_keys) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/media_types/hash.rb', line 11

def slice(*keep_keys)
  if __getobj__.respond_to?(:slice)
    return __getobj__.slice(*keep_keys)
  end

  h = {}
  keep_keys.each { |key| h[key] = fetch(key) if key?(key) }
  h
end