Sha256: 2c56035c2451eb8843449743cd0b92f6f8aeb1dcd596e225953ce1c24716271c
Contents?: true
Size: 856 Bytes
Versions: 14
Compression:
Stored size: 856 Bytes
Contents
# frozen_string_literal: true module Arclight # Render digital object links for a document class EmbedComponent < ViewComponent::Base def initialize(document:, presenter:, **kwargs) super @document = document @presenter = presenter end def render? resources.any? end def embeddable_resources resources.first(1).select { |object| embeddable?(object) } end def linked_resources resources - embeddable_resources end def resources @resources ||= @document.digital_objects || [] end def depth @document.parents.length || 0 end def embeddable?(object) exclude_patterns.none? do |pattern| object.href =~ pattern end end def exclude_patterns Arclight::Engine.config.oembed_resource_exclude_patterns end end end
Version data entries
14 entries across 14 versions & 1 rubygems