Class: Chef::Provisioning::AWSDriver::SuperLWRP

Inherits:
Resource::LWRPBase
  • Object
show all
Defined in:
lib/chef/provisioning/aws_driver/super_lwrp.rb

Direct Known Subclasses

AWSResource

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attribute(attr_name, validation_opts = {}) ⇒ Object

Add the :lazy_default and :coerce validation_opts to ‘attribute`



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/chef/provisioning/aws_driver/super_lwrp.rb', line 10

def self.attribute(attr_name, validation_opts={})
  lazy_default = validation_opts.delete(:lazy_default)
  coerce = validation_opts.delete(:coerce)
  if lazy_default || coerce
    define_method(attr_name) do |arg=nil|
      arg = instance_exec(arg, &coerce) if coerce && !arg.nil?

      result = set_or_return(attr_name.to_sym, arg, validation_opts)

      if result.nil? && arg.nil?
        result = instance_eval(&lazy_default) if lazy_default
      end

      result
    end
    define_method(:"#{attr_name}=") do |arg|
      if arg.nil?
        remove_instance_variable(:"@#{arg}")
      else
        set_or_return(attr_name.to_sym, arg, validation_opts)
      end
    end
  else
    super
  end
end

Instance Method Details

#load_prior_resource(*args) ⇒ Object

FUUUUUU cloning - this works for Chef 11 or 12.1



38
39
40
# File 'lib/chef/provisioning/aws_driver/super_lwrp.rb', line 38

def load_prior_resource(*args)
  Chef::Log.debug "Overloading #{self.resource_name} load_prior_resource with NOOP"
end