Class: MediaTypes::Hash

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/media_types/hash.rb

Direct Known Subclasses

Formatter

Instance Method Summary collapse

Instance Method Details

#===(other) ⇒ Object



7
8
9
# File 'lib/media_types/hash.rb', line 7

def ===(other)
  __getobj__ === other # rubocop:disable Style/CaseEquality
end

#classObject



3
4
5
# File 'lib/media_types/hash.rb', line 3

def class
  __getobj__.class
end

#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