Module: Wrest::Components::Translators
- Defined in:
- lib/wrest/components/translators.rb,
lib/wrest/components/translators/txt.rb,
lib/wrest/components/translators/xml.rb,
lib/wrest/components/translators/html.rb,
lib/wrest/components/translators/json.rb,
lib/wrest/components/translators/content_types.rb,
lib/wrest/components/translators/xml/conversions.rb
Overview
Contains strategies/lambdas which know how to deserialise different content types.
Defined Under Namespace
Constant Summary collapse
- CONTENT_TYPES =
Maps content types to deserialisers
{ 'application/xml' => Wrest::Components::Translators::Xml, 'text/xml' => Wrest::Components::Translators::Xml, 'application/json' => Wrest::Components::Translators::Json, 'text/javascript' => Wrest::Components::Translators::Json, 'text/plain' => Wrest::Components::Translators::Txt, 'text/html' => Wrest::Components::Translators::Html }.freeze
Class Method Summary collapse
-
.lookup(content_type) ⇒ Object
Loads the appropriate desirialisation strategy based on the content type.
Class Method Details
.lookup(content_type) ⇒ Object
Loads the appropriate desirialisation strategy based on the content type
19 20 21 22 |
# File 'lib/wrest/components/translators.rb', line 19 def self.lookup(content_type) translator = CONTENT_TYPES[content_type] translator || (raise Wrest::Exceptions::UnsupportedContentType, "Unsupported content type #{content_type}") end |