Class: Alchemy::Configuration::ConfigurationOption
- Inherits:
-
BaseOption
- Object
- BaseOption
- Alchemy::Configuration::ConfigurationOption
- Defined in:
- lib/alchemy/configuration/configuration_option.rb
Instance Attribute Summary collapse
-
#config_class ⇒ Object
readonly
Returns the value of attribute config_class.
Attributes inherited from BaseOption
Class Method Summary collapse
Instance Method Summary collapse
- #allowed_classes ⇒ Object
-
#initialize(value:, name:, config_class:, **args) ⇒ ConfigurationOption
constructor
A new instance of ConfigurationOption.
- #validate(value) ⇒ Object
Methods inherited from BaseOption
Constructor Details
#initialize(value:, name:, config_class:, **args) ⇒ ConfigurationOption
Returns a new instance of ConfigurationOption.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/alchemy/configuration/configuration_option.rb', line 14 def initialize(value:, name:, config_class:, **args) @name = name @config_class = config_class validate(value) @value = if value.is_a?(config_class) value else config_class.new(value) end end |
Instance Attribute Details
#config_class ⇒ Object (readonly)
Returns the value of attribute config_class.
12 13 14 |
# File 'lib/alchemy/configuration/configuration_option.rb', line 12 def config_class @config_class end |
Class Method Details
.value_class ⇒ Object
8 9 10 |
# File 'lib/alchemy/configuration/configuration_option.rb', line 8 def self.value_class Hash end |
Instance Method Details
#allowed_classes ⇒ Object
30 31 32 |
# File 'lib/alchemy/configuration/configuration_option.rb', line 30 def allowed_classes super + [config_class] end |
#validate(value) ⇒ Object
25 26 27 28 |
# File 'lib/alchemy/configuration/configuration_option.rb', line 25 def validate(value) return true if value.is_a?(config_class) super end |