Class: Maglev::SectionComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Maglev::SectionComponent
- Extended by:
- Forwardable
- Includes:
- TagHelper
- Defined in:
- app/components/maglev/section_component.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#templates_root_path ⇒ Object
readonly
Returns the value of attribute templates_root_path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #blocks ⇒ Object
-
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety.
-
#dom_id ⇒ Object
rubocop:enable Lint/MissingSuper.
-
#initialize(parent:, attributes:, definition:, templates_root_path:) ⇒ SectionComponent
constructor
rubocop:disable Lint/MissingSuper.
- #render ⇒ Object
-
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety.
Methods included from TagHelper
Methods inherited from BaseComponent
#build, #build_content, #build_settings_map, #settings_proxy
Constructor Details
#initialize(parent:, attributes:, definition:, templates_root_path:) ⇒ SectionComponent
rubocop:disable Lint/MissingSuper
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/maglev/section_component.rb', line 13 def initialize(parent:, attributes:, definition:, templates_root_path:) @parent = parent # aka a PageComponent @id = attributes[:id] @type = attributes[:type] @definition = definition @attributes = attributes @templates_root_path = templates_root_path @settings = settings_proxy( build_settings_map(attributes[:settings]) ) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def attributes @attributes end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def definition @definition end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def id @id end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def parent @parent end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def settings @settings end |
#templates_root_path ⇒ Object (readonly)
Returns the value of attribute templates_root_path.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def templates_root_path @templates_root_path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'app/components/maglev/section_component.rb', line 10 def type @type end |
Instance Method Details
#blocks ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/components/maglev/section_component.rb', line 41 def blocks return @blocks if @blocks @blocks = if definition.blocks_presentation == 'tree' build_block_tree else build_block_list end end |
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety
32 33 34 |
# File 'app/components/maglev/section_component.rb', line 32 def dom_data "data-maglev-section-id=\"#{id}\"".html_safe end |
#dom_id ⇒ Object
rubocop:enable Lint/MissingSuper
27 28 29 |
# File 'app/components/maglev/section_component.rb', line 27 def dom_id "section-#{id}" end |
#render ⇒ Object
51 52 53 54 55 56 |
# File 'app/components/maglev/section_component.rb', line 51 def render super( template: "#{templates_root_path}/sections/#{definition.category}/#{type}", locals: { section: self, maglev_section: self } ) end |
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety
37 38 39 |
# File 'app/components/maglev/section_component.rb', line 37 def tag_data { maglev_section_id: id } end |