Class: Kitchen::Terraform::ConfigAttributeDefiner
- Inherits:
-
Object
- Object
- Kitchen::Terraform::ConfigAttributeDefiner
- Defined in:
- lib/kitchen/terraform/config_attribute_definer.rb
Overview
ConfigAttributeDefiner is the class of objects which define configuration attributes on a plugin class.
Instance Method Summary collapse
-
#define(plugin_class:) ⇒ self
#define defines a configuration attribute on a plugin class.
-
#initialize(attribute:, schema:) ⇒ Kitchen::Terraform::ConfigAttributeDefined
constructor
#initialize prepares a new instance of the class.
Constructor Details
#initialize(attribute:, schema:) ⇒ Kitchen::Terraform::ConfigAttributeDefined
#initialize prepares a new instance of the class.
41 42 43 44 |
# File 'lib/kitchen/terraform/config_attribute_definer.rb', line 41 def initialize(attribute:, schema:) self.attribute = attribute.to_sym self.schema = schema end |
Instance Method Details
#define(plugin_class:) ⇒ self
#define defines a configuration attribute on a plugin class.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kitchen/terraform/config_attribute_definer.rb', line 25 def define(plugin_class:) plugin_class.required_config attribute do |_attribute, value, _plugin| process messages: schema.call(value: value).errors.to_h, plugin_class: plugin_class end plugin_class.default_config attribute do |plugin| plugin.send "config_#{attribute}_default_value" end self end |