Class: Maglev::Editor::SettingsGroupComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Maglev::Editor::SettingsGroupComponent
- Defined in:
- app/components/maglev/editor/settings_group_component.rb
Instance Attribute Summary collapse
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(values:, definitions:, scope:, paths: {}) ⇒ SettingsGroupComponent
constructor
A new instance of SettingsGroupComponent.
- #setting_instance_for(definition) ⇒ Object
- #value_of(definition_id) ⇒ Object
Constructor Details
#initialize(values:, definitions:, scope:, paths: {}) ⇒ SettingsGroupComponent
Returns a new instance of SettingsGroupComponent.
8 9 10 11 12 13 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 8 def initialize(values:, definitions:, scope:, paths: {}) @values = values @definitions = definitions @paths = paths @scope = scope end |
Instance Attribute Details
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
6 7 8 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 6 def definitions @definitions end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
6 7 8 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 6 def paths @paths end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
6 7 8 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 6 def scope @scope end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
6 7 8 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 6 def values @values end |
Instance Method Details
#setting_instance_for(definition) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 15 def setting_instance_for(definition) component_klass = Maglev::Editor::SettingRegistry.instance.fetch(definition) component_klass.new( definition: definition, value: value_of(definition.id), paths: paths, scope: scope ) end |
#value_of(definition_id) ⇒ Object
25 26 27 |
# File 'app/components/maglev/editor/settings_group_component.rb', line 25 def value_of(definition_id) values.find { |value| value.id == definition_id }&.value end |