class Chef::Mixin::Deprecation::DeprecatedInstanceVariable

Public Class Methods

new(target, ivar_name, level=nil) click to toggle source
# File lib/chef/mixin/deprecation.rb, line 63
def initialize(target, ivar_name, level=nil)
  @target, @ivar_name = target, ivar_name
  @level ||= :warn
end

Public Instance Methods

inspect() click to toggle source
# File lib/chef/mixin/deprecation.rb, line 73
def inspect
  @target.inspect
end
method_missing(method_name, *args, &block) click to toggle source
# File lib/chef/mixin/deprecation.rb, line 68
def method_missing(method_name, *args, &block)
  log_deprecation_msg(caller[0..3])
  @target.send(method_name, *args, &block)
end

Private Instance Methods

log(msg) click to toggle source
# File lib/chef/mixin/deprecation.rb, line 86
def log(msg)
  # WTF: I don't get the log prefix (i.e., "[timestamp] LEVEL:") if I
  # send to Chef::Log. No one but me should use method_missing, ever.
  Chef::Log.logger.send(@level, msg)
end
log_deprecation_msg(*called_from) click to toggle source
# File lib/chef/mixin/deprecation.rb, line 79
def log_deprecation_msg(*called_from)
  called_from = called_from.flatten
  log("Accessing #{@ivar_name} by the variable @#{@ivar_name} is deprecated. Support will be removed in a future release.")
  log("Please update your cookbooks to use #{@ivar_name} in place of @#{@ivar_name}. Accessed from:")
  called_from.each {|l| log(l)}
end