module Backup::Config::Helpers::ClassMethods
Public Instance Methods
clear_defaults!()
click to toggle source
Used only within the specs
# File lib/backup/config/helpers.rb, line 24 def clear_defaults! defaults.reset! end
defaults() { |defaults| ... }
click to toggle source
# File lib/backup/config/helpers.rb, line 13 def defaults @defaults ||= Config::Defaults.new if block_given? yield @defaults else @defaults end end
deprecations()
click to toggle source
# File lib/backup/config/helpers.rb, line 28 def deprecations @deprecations ||= {} end
log_deprecation_warning(name, deprecation)
click to toggle source
# File lib/backup/config/helpers.rb, line 32 def log_deprecation_warning(name, deprecation) msg = "#{ self }##{ name } has been deprecated as of " + "backup v.#{ deprecation[:version] }" msg << "\n#{ deprecation[:message] }" if deprecation[:message] Logger.warn Config::Error.new(" [DEPRECATION WARNING] #{ msg } ") end
Protected Instance Methods
attr_deprecate(name, args = {})
click to toggle source
Method to deprecate an attribute.
:version
Must be set to the backup version which will first introduce the deprecation.
:action
If set, this Proc will be called with a reference to the class instance and the value set on the deprecated accessor. e.g. deprecation[:action].call(klass, value) This should perform whatever action is neccessary, such as transferring the value to a new accessor.
:message
If set, this will be appended to #log_deprecation_warning
Note that this replaces the `attr_accessor` method, or other method previously used to set the accessor being deprecated. method_missing will handle any calls to `name=`.
# File lib/backup/config/helpers.rb, line 65 def attr_deprecate(name, args = {}) deprecations[name] = { :version => nil, :message => nil, :action => nil }.merge(args) end