Class: SoberSwag::Serializer::Primitive

Inherits:
Base
  • Object
show all
Defined in:
lib/sober_swag/serializer/primitive.rb

Overview

A class that does no serialization: you give it a type, and it will pass any serialized input on verbatim.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#array, #finalize_lazy_type!, #identifier, #lazy_type, #lazy_type?, #meta, #optional, #serializer, #via_map

Constructor Details

#initialize(type) ⇒ Primitive

Construct a primitive serializer with a description of the type it serializes to.

Parameters:

  • type (Class)

    a swagger-able type



10
11
12
# File 'lib/sober_swag/serializer/primitive.rb', line 10

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/sober_swag/serializer/primitive.rb', line 14

def type
  @type
end

Instance Method Details

#serialize(object, _options = {}) ⇒ Object



16
17
18
# File 'lib/sober_swag/serializer/primitive.rb', line 16

def serialize(object, _options = {})
  object
end