Module: KDoc::ComposableComponents
- Defined in:
- lib/k_doc/mixins/composable_components.rb
Overview
Composite Design Pattern: refactoring.guru/design-patterns/composite
Instance Attribute Summary collapse
-
#components ⇒ Object
readonly
Components allow downwards navigation plus access to sub-components.
-
#parent ⇒ Object
readonly
Parent allows upwards navigation to parent component.
Instance Method Summary collapse
Instance Attribute Details
#components ⇒ Object (readonly)
Components allow downwards navigation plus access to sub-components
10 11 12 |
# File 'lib/k_doc/mixins/composable_components.rb', line 10 def components @components end |
#parent ⇒ Object (readonly)
Parent allows upwards navigation to parent component
7 8 9 |
# File 'lib/k_doc/mixins/composable_components.rb', line 7 def parent @parent end |
Instance Method Details
#attach_parent(parent) ⇒ Object
12 13 14 |
# File 'lib/k_doc/mixins/composable_components.rb', line 12 def attach_parent(parent) @parent = parent end |
#navigate_parent ⇒ Object
16 17 18 |
# File 'lib/k_doc/mixins/composable_components.rb', line 16 def navigate_parent parent.nil? ? self : parent end |
#root? ⇒ Boolean
20 21 22 |
# File 'lib/k_doc/mixins/composable_components.rb', line 20 def root? parent.nil? end |