Newer
Older
Mauricio Giacomini Girardello
committed
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
def object_type
object.object_type.try(:name)
end
object.liked? current_user
end
attributes :id,
:name,
:description,
:author,
:thumbnail,
:publisher,
:object_type,
:language,
:default_attachment_id,
:default_location,
:default_mime_type,
:score,
:likes_count,
:shares_count,
:created_at,
:updated_at
has_many :subjects
has_many :educational_stages