Class: OEmbed::CollectionSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/o_embed/collection_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

#author_properties, #generic_properties, #initialize, #link_properties, #model_file_properties, #photo_properties, #renderable_properties, #video_properties

Constructor Details

This class inherits a constructor from OEmbed::ApplicationSerializer

Instance Method Details

#serialize ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/serializers/o_embed/collection_serializer.rb', line 3

def serialize
  {
    title: @object.name
  }.merge(
    generic_properties,
    author_properties(@object.creator),
    @object.cover ?
      {
        type: "photo",
        url: Rails.application.routes.url_helpers.cover_collection_url(@object),
        mediaType: @object.cover.mime_type
      } :
      model_file_properties(
        (ModelPolicy.new(nil, @object.preview_model).show? && @object.preview_model.preview_file) ||
        ModelPolicy::Scope.new(nil, @object.models).resolve.first&.preview_file
      )
  )
end