Module: IceCube::Deprecated
- Included in:
- Schedule, TimeUtil, Validations::Until
- Defined in:
- lib/ice_cube/deprecated.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#deprecated(name, replacement) ⇒ Object
Deprecate a defined method.
-
#deprecated_alias(name, replacement) ⇒ Object
Define a deprecated alias for a method.
Class Method Details
.schedule_options(schedule, options) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ice_cube/deprecated.rb', line 28 def self.(schedule, ) if [:start_date_override] warn "IceCube: :start_date_override option is deprecated " \ "(use a block: `{|s| s.start_time = override }`)", caller(1..1).first schedule.start_time = [:start_date_override] end end |
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: #{self.class}##{name} is deprecated (use #{replacement})", caller(1..1).first 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: #{self.class}##{name} is deprecated (use #{replacement})", caller(1..1).first send replacement, *args, &block end end |