Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Includes:
DeprecatedAttributes
Defined in:
lib/deprecated_attributes/active_record_extension.rb

Overview

rubocop:disable Style/ClassAndModuleChildren Override ActiveRecord arttribute_methods

Constant Summary

Constants included from DeprecatedAttributes

DeprecatedAttributes::VERSION

Instance Method Summary collapse

Methods included from DeprecatedAttributes

configuration, configure, included, reset

Instance Method Details

#attribute_for_inspect(attr_name) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/deprecated_attributes/active_record_extension.rb', line 23

def attribute_for_inspect(attr_name)
  return super unless self.class.deprecated_attributes.include?(attr_name.to_sym)

  attr_name = attr_name.to_s
  attr_name = self.class.attribute_aliases[attr_name] || attr_name
  last_value = _read_attribute(attr_name)

  value = "DEPRECATED with value: #{last_value}"

  format_for_inspect(attr_name, value)
end

#attribute_namesObject



11
12
13
# File 'lib/deprecated_attributes/active_record_extension.rb', line 11

def attribute_names
  self.class.attribute_names.reject { |attr| self.class.deprecated_attributes.include?(attr.to_sym) }
end

#serializable_hash(options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/deprecated_attributes/active_record_extension.rb', line 15

def serializable_hash(options = {})
  options = {} if options.nil?

  options[:only] = attributes.keys.map(&:to_sym) - (self.class.deprecated_attributes || []).map(&:to_sym)

  super(options)
end