module Kitchen::Pulumi::ConfigAttributeCacher
Namespace for the config attribute retrieval cache. Allows plugins that include ConfigAttributes to refer to config values by instance variables of the form 'config_<attribute name>'
Public Class Methods
extended(config_attribute)
click to toggle source
Defines an attribute cache for a config attribute extending this module
# File lib/kitchen/pulumi/config_attribute_cacher.rb, line 10 def self.extended(config_attribute) config_attribute.define_cache end
Public Instance Methods
define_cache(attribute: to_sym)
click to toggle source
Sets an instance variable for a config attribute extending this module
# File lib/kitchen/pulumi/config_attribute_cacher.rb, line 15 def define_cache(attribute: to_sym) attr = "config_#{attribute}" define_method(attr) do if instance_variable_defined?("@#{attr}") instance_variable_get("@#{attr}") else instance_variable_set("@#{attr}", config.fetch(attribute)) end end end