1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
# frozen_string_literal: true
module ActiveRecord # :nodoc:
# = Active Record \Serialization
module Serialization
extend ActiveSupport::Concern
include ActiveModel::Serializers::JSON
included do
self.include_root_in_json = false
end
def serializable_hash(options = nil)
if self.class._has_attribute?(self.class.inheritance_column)
options = options ? options.dup : {}
options[:except] = Array(options[:except]).map(&:to_s)
options[:except] |= Array(self.class.inheritance_column)
end
super(options)
end
private
def attribute_names_for_serialization
attribute_names
end
end
end
|