Class: ShafClient::ResourceMapper
- Inherits:
-
Object
- Object
- ShafClient::ResourceMapper
- Defined in:
- lib/shaf_client/resource_mapper.rb
Class Method Summary collapse
- .all ⇒ Object
- .default=(clazz) ⇒ Object
- .for(content_type) ⇒ Object
- .register(content_type, clazz) ⇒ Object
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/shaf_client/resource_mapper.rb', line 6 def all @all ||= {} end |
.default=(clazz) ⇒ Object
22 23 24 |
# File 'lib/shaf_client/resource_mapper.rb', line 22 def default=(clazz) all.default = clazz end |
.for(content_type) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/shaf_client/resource_mapper.rb', line 10 def for(content_type) all[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
18 19 20 |
# File 'lib/shaf_client/resource_mapper.rb', line 18 def register(content_type, clazz) all[content_type&.to_sym] = clazz end |