Class: Lcms::Engine::ResourceSerializer
- Inherits:
-
ActiveModel::Serializer
- Object
- ActiveModel::Serializer
- Lcms::Engine::ResourceSerializer
- Includes:
- ResourceHelper
- Defined in:
- app/serializers/lcms/engine/resource_serializer.rb
Overview
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)
Direct Known Subclasses
Instance Method Summary collapse
- #breadcrumb_title ⇒ Object
- #grade ⇒ Object
-
#is_assessment ⇒ Object
rubocop:disable Naming/PredicateName.
-
#is_foundational ⇒ Object
rubocop:disable Naming/PredicateName.
-
#is_opr ⇒ Object
rubocop:disable Naming/PredicateName.
-
#is_prerequisite ⇒ Object
rubocop:disable Naming/PredicateName.
- #path ⇒ Object
- #type ⇒ Object
Methods included from ResourceHelper
#back_to_resource_path, #copyrights_text, #download_per_category_limit, #prerequisites_standards, #resource_breadcrumbs_with_links, #show_resource_path, #type_name
Instance Method Details
#breadcrumb_title ⇒ Object
14 15 16 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 14 def Breadcrumbs.new(object).title end |
#grade ⇒ Object
18 19 20 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 18 def grade object.grades.average end |
#is_assessment ⇒ Object
rubocop:disable Naming/PredicateName
22 23 24 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 22 def is_assessment # rubocop:disable Naming/PredicateName object&.assessment? || short_title&.index('assessment').present? end |
#is_foundational ⇒ Object
rubocop:disable Naming/PredicateName
26 27 28 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 26 def is_foundational # rubocop:disable Naming/PredicateName object.document&.foundational? end |
#is_opr ⇒ Object
rubocop:disable Naming/PredicateName
30 31 32 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 30 def is_opr # rubocop:disable Naming/PredicateName object.opr? end |
#is_prerequisite ⇒ Object
rubocop:disable Naming/PredicateName
34 35 36 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 34 def is_prerequisite # rubocop:disable Naming/PredicateName object.prerequisite? end |
#path ⇒ Object
38 39 40 41 42 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 38 def path return document_path(object.document) if object.document? && !object.assessment? show_resource_path(object) end |
#type ⇒ Object
44 45 46 |
# File 'app/serializers/lcms/engine/resource_serializer.rb', line 44 def type object.curriculum_type end |