Class: Lcms::Engine::ResourceDetailsSerializer

Inherits:
ResourceSerializer
  • Object
show all
Includes:
ResourceHelper
Defined in:
app/serializers/lcms/engine/resource_details_serializer.rb

Overview

This is a superset of ResourceSerializer, meant to be used were we need associations and other info. Currently is used on ExploreCurriculums (together with the CurriculumResourceSerializer)

Instance Method Summary collapse

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

Methods inherited from ResourceSerializer

#breadcrumb_title, #grade, #is_assessment, #is_foundational, #is_opr, #is_prerequisite, #path, #type

Instance Method Details



32
33
34
# File 'app/serializers/lcms/engine/resource_details_serializer.rb', line 32

def copyright
  copyrights_text(object)
end

#downloadsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/serializers/lcms/engine/resource_details_serializer.rb', line 15

def downloads
  serialize_download = lambda do |download|
    next unless download.is_a?(ResourceDownload)

    indent = object.pdf_downloads? download.download_category
    {
      id: download.id,
      icon: h.file_icon(download.download.attachment_content_type),
      title: download.download.title,
      url: download_path(download, slug: object.slug),
      preview_url: preview_download_path(id: download, slug: object.slug),
      indent: indent
    }
  end
  object.download_categories.map { |k, v| [k, v.map(&serialize_download)] }
end

rubocop:disable Naming/PredicateName



36
37
38
# File 'app/serializers/lcms/engine/resource_details_serializer.rb', line 36

def has_related # rubocop:disable Naming/PredicateName
  false
end

#opr_standardsObject



40
41
42
43
44
# File 'app/serializers/lcms/engine/resource_details_serializer.rb', line 40

def opr_standards
  return unless object.opr? && object.document.present?

  DocumentGenerator.document_presenter.new(object.document).standards
end