Class: ResponseDescriptor

Inherits:
Object
  • Object
show all
Includes:
Hyperion::Headers
Defined in:
lib/hyperion/types/response_descriptor.rb

Constant Summary

Constants included from Hyperion::Headers

Hyperion::Headers::ContentTypes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Hyperion::Headers

#content_type_for, #format_for, #route_headers, #short_mimetype

Constructor Details

#initialize(type, version, format) ⇒ ResponseDescriptor

Returns a new instance of ResponseDescriptor.

Parameters:

  • type (String)
  • version (Integer)
  • format (Symbol)

    :json



13
14
15
# File 'lib/hyperion/types/response_descriptor.rb', line 13

def initialize(type, version, format)
  @type, @version, @format = type, version, format
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



8
9
10
# File 'lib/hyperion/types/response_descriptor.rb', line 8

def format
  @format
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/hyperion/types/response_descriptor.rb', line 8

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



8
9
10
# File 'lib/hyperion/types/response_descriptor.rb', line 8

def version
  @version
end

Instance Method Details

#as_json(*_args) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/hyperion/types/response_descriptor.rb', line 17

def as_json(*_args)
  {
      'type' => type,
      'version' => version,
      'format' => format.to_s
  }
end

#to_sObject



25
26
27
# File 'lib/hyperion/types/response_descriptor.rb', line 25

def to_s
  short_mimetype(self)
end