Module: Deprecated

Included in:
IceCube::Schedule, IceCube::Validations::Until
Defined in:
lib/ice_cube/deprecated.rb

Instance Method Summary collapse

Instance Method Details

#deprecated(name, replacement) ⇒ Object

Deprecate a defined method

Parameters:

  • name (Symbol)
    • name of deprecated method

  • replacement (Symbol)
    • name of the desired replacement



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

Parameters:

  • name (Symbol)
    • name of method to define

  • replacement (Symbol)
    • name of method to replace (alias)



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