Module: Nestful::Formats

Defined in:
lib/nestful/formats.rb,
lib/nestful/formats/form_format.rb,
lib/nestful/formats/json_format.rb

Defined Under Namespace

Classes: FormFormat, Format, JSONFormat

Constant Summary collapse

MAPPING =
{
  'application/json' => :json
}
JsonFormat =
JSONFormat

Class Method Summary collapse

Class Method Details

.[](mime_type_reference) ⇒ Object

Lookup the format class from a mime type reference symbol. Example:

Nestful::Formats[:json] # => Nestful::Formats::JsonFormat

26
27
28
# File 'lib/nestful/formats.rb', line 26

def self.[](mime_type_reference)
  Nestful::Formats.const_get(Helpers.camelize(mime_type_reference.to_s) + 'Format')
end

.for(type) ⇒ Object


18
19
20
21
# File 'lib/nestful/formats.rb', line 18

def self.for(type)
  format = MAPPING[type]
  format && self[format]
end