Module: Chef::Mixin::Deprecation

Included in:
Client, Recipe, Resource
Defined in:
lib/chef/mixin/deprecation.rb

Defined Under Namespace

Classes: DeprecatedInstanceVariable, DeprecatedObjectProxyBase

Instance Method Summary collapse

Instance Method Details

#deprecated_attr(name, alternative) ⇒ Object



97
98
99
100
# File 'lib/chef/mixin/deprecation.rb', line 97

def deprecated_attr(name, alternative)
  deprecated_attr_reader(name, alternative)
  deprecated_attr_writer(name, alternative)
end

#deprecated_attr_reader(name, alternative, level = :warn) ⇒ Object



102
103
104
105
106
107
# File 'lib/chef/mixin/deprecation.rb', line 102

def deprecated_attr_reader(name, alternative, level = :warn)
  define_method(name) do
    Chef.deprecated(:internal_api, "#{self.class}.#{name} is deprecated. Support will be removed in a future release. #{alternative}")
    instance_variable_get("@#{name}")
  end
end

#deprecated_attr_writer(name, alternative, level = :warn) ⇒ Object



109
110
111
112
113
114
# File 'lib/chef/mixin/deprecation.rb', line 109

def deprecated_attr_writer(name, alternative, level = :warn)
  define_method("#{name}=") do |value|
    Chef.deprecated(:internal_api, "Writing to #{self.class}.#{name} with #{name}= is deprecated. Support will be removed in a future release. #{alternative}")
    instance_variable_set("@#{name}", value)
  end
end

#deprecated_ivar(obj, name, level = nil) ⇒ Object



93
94
95
# File 'lib/chef/mixin/deprecation.rb', line 93

def deprecated_ivar(obj, name, level = nil)
  DeprecatedInstanceVariable.new(obj, name, level)
end