1require 'active_support/deprecation'
 
2
 
3module DeprecatedAttributes
 
4  extend ActiveSupport::Concern
 
5
 
6  class_methods do
  • DuplicateMethodCall - calls 'caller_locations(0)' 3 times » reek
  • DuplicateMethodCall - calls 'caller_locations(0).map(&:to_s)' 3 times » reek
  • DuplicateMethodCall - calls 'caller_locations(0).map(&:to_s).reject' 3 times » reek
  • DuplicateMethodCall - calls 'caller_locations(0).map(&:to_s).reject{ |path| path =~ /deprecated_attributes\.rb/ }' 3 times » reek
  • DuplicateMethodCall - calls 'path =~ /deprecated_attributes\.rb/' 3 times » reek
  • DuplicateMethodCall - calls 'self.class' 3 times » reek
  • DuplicateMethodCall - calls 'self.class.name' 3 times » reek
  • NestedIterators - contains iterators nested 2 deep » reek
  • NestedIterators - contains iterators nested 3 deep » reek
  • TooManyStatements - has approx 16 statements » reek
  • Complexity 8 » saikuro
7    def deprecate_attribute(*names)
 
8      names.each do |name|
 
 9        define_method(:"#{name}") do
 
10          callstack = caller_locations(0).map(&:to_s).reject{ |path| path =~ /deprecated_attributes\.rb/ }
 
11          ActiveSupport::Deprecation.warn("#{self.class.name}##{name} is deprecated and will be removed", callstack)
 
12          super()
 
13        end
 
 
15        define_method(:"#{name}=") do |value|
 
16          callstack = caller_locations(0).map(&:to_s).reject{ |path| path =~ /deprecated_attributes\.rb/ }
 
17          ActiveSupport::Deprecation.warn("#{self.class.name}##{name}= is deprecated and will be removed", callstack)
 
18          super(value)
 
19        end
 
 
21        define_method(:"#{name}?") do
 
22          callstack = caller_locations(0).map(&:to_s).reject{ |path| path =~ /deprecated_attributes\.rb/ }
 
23          ActiveSupport::Deprecation.warn("#{self.class.name}##{name}? is deprecated and will be removed", callstack)
 
24          super()
 
25        end
 
26      end
 
27    end
 
28  end
 
29end