Class: CookbookOmnifetch::Integration
- Inherits:
-
Object
- Object
- CookbookOmnifetch::Integration
- Defined in:
- lib/cookbook-omnifetch/integration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Integration
constructor
A new instance of Integration.
Constructor Details
#initialize ⇒ Integration
Returns a new instance of Integration.
39 40 41 42 43 |
# File 'lib/cookbook-omnifetch/integration.rb', line 39 def initialize self.class.configurables.each do |configurable| instance_variable_set("@#{configurable}".to_sym, NullValue.new) end end |
Class Method Details
.configurable(name) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cookbook-omnifetch/integration.rb', line 15 def self.configurable(name) configurables << name attr_writer name define_method(name) do value = instance_variable_get("@#{name}".to_sym) case value when NullValue raise MissingConfiguration, "`#{name}` is not configured" when Proc value.call else value end end end |
.configurables ⇒ Object
11 12 13 |
# File 'lib/cookbook-omnifetch/integration.rb', line 11 def self.configurables @configurables ||= [] end |