Module: ROM::Deprecations

Defined in:
lib/rom/support/deprecations.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.announce(name, msg) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/rom/support/deprecations.rb', line 28

def self.announce(name, msg)
  warn "    \#{name} deprecated and will be removed in 1.0.0.\n    \#{msg}\n    \#{caller.detect { |l| !l.include?('lib/rom')}}\n  MSG\nend\n".gsub(/^\s+/, '')

Instance Method Details

#deprecate(old_name, new_name, msg = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/rom/support/deprecations.rb', line 4

def deprecate(old_name, new_name, msg = nil)
  class_eval do
    define_method(old_name) do |*args, &block|
      ROM::Deprecations.announce "#{self.class}##{old_name} is", "        Please use \#{self.class}#\#{new_name} instead.\n        \#{msg}\n      MSG\n      __send__(new_name, *args, &block)\n    end\n  end\nend\n"

#deprecate_class_method(old_name, new_name, msg = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rom/support/deprecations.rb', line 16

def deprecate_class_method(old_name, new_name, msg = nil)
  class_eval do
    define_singleton_method(old_name) do |*args, &block|
      ROM::Deprecations.announce"#{self}.#{old_name} is", "        Please use \#{self}.\#{new_name} instead.\n        \#{msg}\n      MSG\n      __send__(new_name, *args, &block)\n    end\n  end\nend\n"