Module Wrest::Components::Translators

  1. lib/wrest/components/translators/content_types.rb
  2. lib/wrest/components/translators/xml.rb
  3. lib/wrest/components/translators.rb
  4. show all

Contains strategies/lambdas which know how to deserialise different content types.

Methods

public class

  1. lookup

Constants

CONTENT_TYPES = { 'application/xml' => Wrest::Components::Translators::Xml, 'text/xml' => Wrest::Components::Translators::Xml, 'application/json' => Wrest::Components::Translators::Json, 'text/javascript' => Wrest::Components::Translators::Json }   Maps content types to deserialisers

Public class methods

lookup (content_type)

Loads the appropriate desirialisation strategy based on the content type

[show source]
    # File lib/wrest/components/translators.rb, line 18
18:       def self.lookup(content_type)
19:         translator = CONTENT_TYPES[content_type]
20:         translator || (raise Wrest::Exceptions::UnsupportedContentType.new("Unsupported content type #{content_type}"))
21:       end