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) end def thumbnail object.default_thumbnail end def object_type object.object_type.try(:name) end attributes :id, :name, :description, :author, :thumbnail, :publisher, :object_type, :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 end