Sha256: 0dbeea9d645e989d2b822041e7c269244e9dc7a989d6f43acc0068f1a4743eb6
Contents?: true
Size: 1.4 KB
Versions: 12
Compression:
Stored size: 1.4 KB
Contents
# frozen_string_literal: true module Lcms module Engine # This is a subset of the previous ResourceSerializer, meant to be used on listings # like find_lessons and search cards. We use this instead the full version (ResourceDetailsSerializer) # to avoid expensive queries on data we don't need (like downloads, and related) class ResourceSerializer < ActiveModel::Serializer include ResourceHelper attributes :breadcrumb_title, :grade, :id, :is_assessment, :is_foundational, :is_opr, :is_prerequisite, :path, :short_title, :subject, :teaser, :time_to_teach, :title, :type def breadcrumb_title Breadcrumbs.new(object).title end def grade object.grades.average end def is_assessment # rubocop:disable Naming/PredicateName object&.assessment? || short_title&.index('assessment').present? end def is_foundational # rubocop:disable Naming/PredicateName object.document&.foundational? end def is_opr # rubocop:disable Naming/PredicateName object.opr? end def is_prerequisite # rubocop:disable Naming/PredicateName object.prerequisite? end def path return document_path(object.document) if object.document? && !object.assessment? show_resource_path(object) end def type object.curriculum_type end end end end
Version data entries
12 entries across 12 versions & 1 rubygems