Skip to content
Snippets Groups Projects
learning_object_serializer.rb 603 B
Newer Older
class LearningObjectSerializer < ActiveModel::Serializer
  def default_location
    object.default_attachment.try(:retrieve_url)
  end

  def default_mime_type
    object.default_attachment.try(:mime_type)
  end

  def default_attachment_id
    object.default_attachment.try(:id)
  def thumbnail
    object.default_thumbnail
  end

  attributes :id, :name, :description, :author, :thumbnail, :publisher, :language, :default_attachment_id, :default_location, :default_mime_type, :score, :license, :likes_count, :shares_count, :created_at, :updated_at
  has_many :tags
  has_many :attachments