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.
-
#rendering_mode ⇒ Object
readonly
Returns the value of attribute rendering_mode.
-
#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
-
#dom_id ⇒ Object
rubocop:enable Lint/MissingSuper.
-
#initialize(parent:, attributes:, definition:, templates_root_path:, rendering_mode:) ⇒ SectionComponent
constructor
rubocop:disable Lint/MissingSuper.
- #lock_version ⇒ Object
- #render ⇒ Object
- #tag_data ⇒ Object
Methods included from TagHelper
Methods inherited from BaseComponent
#build, #build_content, #build_settings_map, #settings_proxy
Methods included from Inspector
Constructor Details
#initialize(parent:, attributes:, definition:, templates_root_path:, rendering_mode:) ⇒ SectionComponent
rubocop:disable Lint/MissingSuper
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/maglev/section_component.rb', line 19 def initialize(parent:, attributes:, definition:, templates_root_path:, rendering_mode:) @parent = parent # aka a PageComponent @id = attributes[:id] @type = attributes[:type] @definition = definition @attributes = attributes @templates_root_path = templates_root_path @rendering_mode = rendering_mode @settings = settings_proxy( build_settings_map(attributes[:settings]) ) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def attributes @attributes end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def definition @definition end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def id @id end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def parent @parent end |
#rendering_mode ⇒ Object (readonly)
Returns the value of attribute rendering_mode.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def rendering_mode @rendering_mode end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def settings @settings end |
#templates_root_path ⇒ Object (readonly)
Returns the value of attribute templates_root_path.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def templates_root_path @templates_root_path end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
15 16 17 |
# File 'app/components/maglev/section_component.rb', line 15 def type @type end |
Instance Method Details
#blocks ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'app/components/maglev/section_component.rb', line 50 def blocks return @blocks if @blocks @blocks = if definition.blocks_presentation == 'tree' build_block_tree else build_block_list end end |
#dom_data ⇒ Object
42 43 44 |
# File 'app/components/maglev/section_component.rb', line 42 def dom_data view_context.tag.attributes(data: tag_data) end |
#dom_id ⇒ Object
rubocop:enable Lint/MissingSuper
34 35 36 |
# File 'app/components/maglev/section_component.rb', line 34 def dom_id @dom_id ||= "section-#{id}" end |
#lock_version ⇒ Object
38 39 40 |
# File 'app/components/maglev/section_component.rb', line 38 def lock_version @lock_version ||= lock_source&.lock_version || '0' end |
#render ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'app/components/maglev/section_component.rb', line 60 def render super( template: "#{templates_root_path}/sections/#{definition.category}/#{type}", locals: { section: self, maglev_section: self } ) rescue StandardError => e handle_error(e) end |
#tag_data ⇒ Object
46 47 48 |
# File 'app/components/maglev/section_component.rb', line 46 def tag_data { maglev_section_id: id, maglev_section_type: type, maglev_section_lock_version: lock_version } end |