Module: IceCube::Deprecated

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

Class Method Summary collapse

Instance Method Summary collapse

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_options(schedule, options)
  if options[: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 = options[:start_date_override]
  end
end

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: #{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

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: #{self.class}##{name} is deprecated (use #{replacement})", caller(1..1).first
    send replacement, *args, &block
  end
end