Class: Modern::Descriptor::Converters::Input::Base

Inherits:
Struct
  • Object
show all
Defined in:
lib/modern/descriptor/converters/input/base.rb

Overview

An input converter takes a raw HTTP request body (as a ‘StringIO`) and returns a Ruby object. A JSON converter would return a hash, for example; a converter for ’image/* might return the ‘StringIO` object without alteration. The results of this converter will be passed into against a Types::Type if one has been provided (which will cause a validation check) before being passed into the route action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Struct::Copy

#copy

Constructor Details

#initialize(fields) ⇒ Base

Returns a new instance of Base.



18
19
20
21
# File 'lib/modern/descriptor/converters/input/base.rb', line 18

def initialize(fields)
  super
  @content_type = ContentType.parse(media_type).freeze
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



16
17
18
# File 'lib/modern/descriptor/converters/input/base.rb', line 16

def content_type
  @content_type
end