Class: Arclight::EmbedComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Arclight::EmbedComponent
- Defined in:
- app/components/arclight/embed_component.rb
Overview
Render digital object links for a document
Instance Method Summary collapse
- #depth ⇒ Object
- #embeddable?(object) ⇒ Boolean
- #embeddable_resources ⇒ Object
- #exclude_patterns ⇒ Object
-
#initialize(document:, presenter:, **kwargs) ⇒ EmbedComponent
constructor
A new instance of EmbedComponent.
- #linked_resources ⇒ Object
- #render? ⇒ Boolean
- #resources ⇒ Object
Constructor Details
#initialize(document:, presenter:, **kwargs) ⇒ EmbedComponent
Returns a new instance of EmbedComponent.
6 7 8 9 10 11 |
# File 'app/components/arclight/embed_component.rb', line 6 def initialize(document:, presenter:, **kwargs) super @document = document @presenter = presenter end |
Instance Method Details
#depth ⇒ Object
29 30 31 |
# File 'app/components/arclight/embed_component.rb', line 29 def depth @document.parents.length || 0 end |
#embeddable?(object) ⇒ Boolean
33 34 35 36 37 |
# File 'app/components/arclight/embed_component.rb', line 33 def (object) exclude_patterns.none? do |pattern| object.href =~ pattern end end |
#embeddable_resources ⇒ Object
17 18 19 |
# File 'app/components/arclight/embed_component.rb', line 17 def resources.first(1).select { |object| (object) } end |
#exclude_patterns ⇒ Object
39 40 41 |
# File 'app/components/arclight/embed_component.rb', line 39 def exclude_patterns Arclight::Engine.config. end |
#linked_resources ⇒ Object
21 22 23 |
# File 'app/components/arclight/embed_component.rb', line 21 def linked_resources resources - end |
#render? ⇒ Boolean
13 14 15 |
# File 'app/components/arclight/embed_component.rb', line 13 def render? resources.any? end |
#resources ⇒ Object
25 26 27 |
# File 'app/components/arclight/embed_component.rb', line 25 def resources @resources ||= @document.digital_objects || [] end |