Class: Chef::Mixin::ParamsValidate::SetOrReturnProperty Private

Inherits:
Property
  • Object
show all
Defined in:
lib/chef/mixin/params_validate.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Used by #set_or_return to avoid emitting a deprecation warning for “value nil” and to keep default stickiness working exactly the same

Instance Attribute Summary

Attributes inherited from Property

#options

Instance Method Summary collapse

Methods inherited from Property

#coerce, #declared_in, #default, #default_description, #derive, derive, #description, #desired_state?, emit_deprecated_alias, #emit_dsl, #equal_to, #explicitly_accepts_nil?, #get_value, #has_default?, #identity?, #initialize, #instance_variable_name, #introduced, #is_set?, #name, #name_property?, #required?, #reset, #reset_value, #sensitive?, #set, #set_value, #skip_docs?, #to_s, #validate, #validation_options, #value_is_set?

Constructor Details

This class inherits a constructor from Chef::Property

Instance Method Details

#call(resource, value = NOT_PASSED) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



495
496
497
498
499
500
501
502
# File 'lib/chef/mixin/params_validate.rb', line 495

def call(resource, value = NOT_PASSED)
  # setting to nil does a get
  if value.nil? && !explicitly_accepts_nil?(resource)
    get(resource, nil_set: true)
  else
    super
  end
end

#get(resource, nil_set: false) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



486
487
488
489
490
491
492
493
# File 'lib/chef/mixin/params_validate.rb', line 486

def get(resource, nil_set: false)
  value = super
  # All values are sticky, frozen or not
  unless is_set?(resource)
    set_value(resource, value)
  end
  value
end