Class: Maglev::BlockComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Maglev::BlockComponent
- Extended by:
- Forwardable
- Includes:
- TagHelper
- Defined in:
- app/components/maglev/block_component.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#children ⇒ Object
Returns the value of attribute children.
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from BaseComponent
Instance Method Summary collapse
-
#children? ⇒ Boolean
rubocop:enable Lint/MissingSuper.
-
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety.
- #dom_id ⇒ Object
-
#initialize(section:, attributes:, definition:) ⇒ BlockComponent
constructor
rubocop:disable Lint/MissingSuper.
-
#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(section:, attributes:, definition:) ⇒ BlockComponent
rubocop:disable Lint/MissingSuper
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/maglev/block_component.rb', line 14 def initialize(section:, attributes:, definition:) @section = section @id = attributes[:id] @name = attributes[:name] @type = attributes[:type] @children = children @definition = definition @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/block_component.rb', line 10 def attributes @attributes end |
#children ⇒ Object
Returns the value of attribute children.
11 12 13 |
# File 'app/components/maglev/block_component.rb', line 11 def children @children end |
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def definition @definition end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def name @name end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def section @section end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def settings @settings end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'app/components/maglev/block_component.rb', line 10 def type @type end |
Instance Method Details
#children? ⇒ Boolean
rubocop:enable Lint/MissingSuper
28 29 30 |
# File 'app/components/maglev/block_component.rb', line 28 def children? children.present? end |
#dom_data ⇒ Object
rubocop:disable Rails/OutputSafety
37 38 39 |
# File 'app/components/maglev/block_component.rb', line 37 def dom_data "data-maglev-block-id=\"#{id}\"".html_safe end |
#dom_id ⇒ Object
32 33 34 |
# File 'app/components/maglev/block_component.rb', line 32 def dom_id "block-#{id}" end |
#tag_data ⇒ Object
rubocop:enable Rails/OutputSafety
42 43 44 |
# File 'app/components/maglev/block_component.rb', line 42 def tag_data { maglev_block_id: id } end |