2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2007-09-20 19:22:30 -04:00
|
|
|
module ActiveRecord #:nodoc:
|
2015-07-08 06:16:16 -04:00
|
|
|
# = Active Record \Serialization
|
2007-09-20 19:22:30 -04:00
|
|
|
module Serialization
|
2009-08-13 23:27:09 -04:00
|
|
|
extend ActiveSupport::Concern
|
2011-11-30 12:38:28 -05:00
|
|
|
include ActiveModel::Serializers::JSON
|
2009-08-13 23:27:09 -04:00
|
|
|
|
2012-05-25 10:58:16 -04:00
|
|
|
included do
|
2013-03-04 14:30:05 -05:00
|
|
|
self.include_root_in_json = false
|
2012-05-25 10:58:16 -04:00
|
|
|
end
|
|
|
|
|
2009-08-13 23:27:09 -04:00
|
|
|
def serializable_hash(options = nil)
|
2017-02-08 11:20:38 -05:00
|
|
|
options = options.try(:dup) || {}
|
2009-08-13 23:27:09 -04:00
|
|
|
|
2014-10-27 12:28:53 -04:00
|
|
|
options[:except] = Array(options[:except]).map(&:to_s)
|
2012-01-05 22:53:29 -05:00
|
|
|
options[:except] |= Array(self.class.inheritance_column)
|
2009-08-13 23:27:09 -04:00
|
|
|
|
2011-02-22 01:55:49 -05:00
|
|
|
super(options)
|
2009-08-13 23:27:09 -04:00
|
|
|
end
|
2007-09-20 19:22:30 -04:00
|
|
|
end
|
|
|
|
end
|