Class: ShafClient::ResourceMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf_client/resource_mapper.rb

Class Method Summary collapse

Class Method Details

.default=(clazz) ⇒ Object



22
23
24
# File 'lib/shaf_client/resource_mapper.rb', line 22

def default=(clazz)
  mapping.default = clazz
end

.for(content_type) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/shaf_client/resource_mapper.rb', line 6

def for(content_type)
  mapping[content_type&.to_sym].tap do |clazz|
    next if clazz
    raise UnSupportedContentType,
      "Can't handle Content-Type: #{content_type}"
  end
end

.register(content_type, clazz) ⇒ Object



14
15
16
# File 'lib/shaf_client/resource_mapper.rb', line 14

def register(content_type, clazz)
  mapping[content_type&.to_sym] = clazz
end

.unregister(content_type) ⇒ Object



18
19
20
# File 'lib/shaf_client/resource_mapper.rb', line 18

def unregister(content_type)
  mapping.delete(content_type.to_sym)
end