module Cocooned::Helpers::Deprecate
Extend the standard Gem::Deprecation module to add a deprecation method that specify the gem release where methods will disappear instead of a date.
Public Instance Methods
deprecate_release(name, replacement, release = '3.0')
click to toggle source
# File lib/cocooned/helpers/deprecate.rb, line 24 def deprecate_release(name, replacement, release = '3.0') class_eval do old = "_deprecated_#{name}" alias_method old, name define_method name do |*args, &block| klass = is_a? Module target = klass ? "#{self}." : "#{self.class}#" unless Gem::Deprecate.skip warn(deprecate_release_message( "#{target}#{name}", replacement, release, Gem.location_of_caller.join(':') )) end send old, *args, &block end end end
deprecate_release_message(target_and_name, replacement, release = '3.0', location = nil)
click to toggle source
# File lib/cocooned/helpers/deprecate.rb, line 15 def deprecate_release_message(target_and_name, replacement, release = '3.0', location = nil) [ "NOTE: #{target_and_name} is deprecated", replacement == :none ? ' with no replacement' : "; use #{replacement} instead", format('. It will dissapear in %<release>s.', release: release), location.nil? ? '' : "\n#{target_and_name} called from #{location}" ].join.strip end