Module: Deprecated
- Included in:
- IceCube::Schedule, IceCube::Validations::Until
- Defined in:
- lib/ice_cube/deprecated.rb
Instance Method Summary collapse
-
#deprecated(name, replacement) ⇒ Object
Deprecate a defined method.
-
#deprecated_alias(name, replacement) ⇒ Object
Define a deprecated alias for a method.
Instance Method Details
#deprecated(name, replacement) ⇒ Object
Deprecate a defined method
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ice_cube/deprecated.rb', line 17 def deprecated(name, replacement) # Replace old method old_name = :"#{name}_without_deprecation" alias_method old_name, name # And replace it with a wrapped version define_method(name) do |*args, &block| warn "IceCube: ##{name} deprecated (please use ##{replacement})" send old_name, *args, &block end end |
#deprecated_alias(name, replacement) ⇒ Object
Define a deprecated alias for a method
6 7 8 9 10 11 12 |
# File 'lib/ice_cube/deprecated.rb', line 6 def deprecated_alias(name, replacement) # Create a wrapped version define_method(name) do |*args, &block| warn "IceCube: ##{name} deprecated (please use ##{replacement})" send replacement, *args, &block end end |