Class: ManyfoldApi::V0::CreatorDeserializer

Inherits:
BaseDeserializer show all
Defined in:
app/deserializers/manyfold_api/v0/creator_deserializer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseDeserializer

#dereference, #initialize, schema_ref, schema_ref_name

Constructor Details

This class inherits a constructor from ManyfoldApi::V0::BaseDeserializer

Class Method Details

.schema ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/deserializers/manyfold_api/v0/creator_deserializer.rb', line 14

def self.schema
  {
    type: :object,
    properties: {
      name: {type: :string, example: "Bruce Wayne"},
      slug: {type: :string, example: "bruce-wayne"},
      caption: {type: :string, example: "A short description"},
      description: {type: :string, example: "Lorem ipsum dolor sit amet..."}, # rubocop:disable I18n/RailsI18n/DecorateString
      links: {
        type: :array,
        items: LinkDeserializer.schema_ref
      }
    },
    required: ["name"]
  }
end

Instance Method Details

#deserialize ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/deserializers/manyfold_api/v0/creator_deserializer.rb', line 3

def deserialize
  return unless @object
  {
    name: @object["name"],
    slug: @object["slug"],
    caption: @object["caption"],
    notes: @object["description"],
    links_attributes: @object["links"]&.map { LinkDeserializer.new(object: it, user: @user).deserialize }
  }.compact
end