Newer
Older
class LearningObjectObaaSerializer < ActiveModel::Serializer
# "educational": {
# "description": "? não existe no PortalMecHomologa"
# },
def general
{
title: object.name,
description: object.description,
keywords: object.tags.map(&:name).join(','),
created_at: object.created_at,
updated_at: object.updated_at,
thumbnail: object.default_thumbnail,
score: object.score,
likes_count: object.likes_count,
shares_count: object.shares_count,
acessibility: ''
}
end
def identifier
{
catalog: 'PortalMec',
entry: object.id,
language: object.language.try(:code)
}
end
def technical
{
location: object.default_attachment.try(:retrieve_url),
format: object.default_attachment.try(:mime_type)
}
end
def rights
{
copyrightAndOhterRestrictions: 'true',
cost: 'false',
description: object.license.try(:name)
}
end
def metametadata
{
identifier: {
catalog: 'PortalMec',
name: object.publisher.try(:name),
entry_type: object.publisher.class.name,
entry: object.publisher.try(:id)
},
contribute: {
role: 'Criador',
entity: object.author,
date: object.created_at
},
metadataSchema: 'OBAAv1.0',
language: object.language.try(:name)
}
end
# attributes :id , :name, :created_at, :updated_at, :description, :author, :score, :likes_count
attributes :id, :general, :identifier, :technical, :rights, :metametadata
# has_many :tags
# has_many :attachments
end