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 62 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 72 def inspect @target.inspect end
method_missing(method_name, *args, &block)
click to toggle source
# File lib/chef/mixin/deprecation.rb, line 67 def method_missing(method_name, *args, &block) deprecated_msg(caller[0..3]) @target.send(method_name, *args, &block) end
Private Instance Methods
deprecated_msg(*called_from)
click to toggle source
# File lib/chef/mixin/deprecation.rb, line 78 def deprecated_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
log(msg)
click to toggle source
# File lib/chef/mixin/deprecation.rb, line 85 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