Module: Cocooned::Helpers::Deprecate
- Extended by:
- Gem::Deprecate
- Included in:
- CocoonCompatibility
- Defined in:
- lib/cocooned/helpers/deprecate.rb
Overview
Extend the standard Gem::Deprecation module to add a deprecation method that specify the gem release where methods will disappear instead of a date.
Class Method Summary collapse
- .deprecate_release(name, replacement, release = '2.0') ⇒ Object
- .deprecate_release_message(target_and_name, replacement, release = '2.0', location = nil) ⇒ Object
Class Method Details
.deprecate_release(name, replacement, release = '2.0') ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cocooned/helpers/deprecate.rb', line 24 def deprecate_release(name, replacement, release = '2.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(( "#{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 = '2.0', location = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cocooned/helpers/deprecate.rb', line 13 def (target_and_name, replacement, release = '2.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 |