Class: ManyfoldApi::V0::CollectionDeserializer
- Inherits:
-
BaseDeserializer
- Object
- BaseDeserializer
- ManyfoldApi::V0::CollectionDeserializer
- Defined in:
- app/deserializers/manyfold_api/v0/collection_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
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/deserializers/manyfold_api/v0/collection_deserializer.rb', line 16 def self.schema { type: :object, properties: { name: {type: :string, example: "Interesting Things"}, 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 }, creator: { type: :object, properties: { "@id": {type: :string, example: "https://example.com/creators/abc123"}, "@type": {type: :string, example: "Organization"} }, required: ["@id"] }, isPartOf: { type: :object, properties: { "@id": {type: :string, example: "https://example.com/collections/abc123"}, "@type": {type: :string, example: "Collection"} }, required: ["@id"] }, preview_file: { type: :object, properties: { "@id": {type: :string, example: "https://example.com/models/abc123"}, "@type": {type: :string, example: "3DModel"} }, required: ["@id"] } }, required: ["name"] } end |
Instance Method Details
#deserialize ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/deserializers/manyfold_api/v0/collection_deserializer.rb', line 3 def deserialize return unless @object { name: @object["name"], creator: dereference(@object.dig("creator", "@id"), Creator), collection: dereference(@object.dig("isPartOf", "@id"), Collection), caption: @object["caption"], notes: @object["description"], preview_model: dereference(@object.dig("preview_model", "@id"), Model), links_attributes: @object["links"]&.map { LinkDeserializer.new(object: it, user: @user).deserialize } }.compact end |