2007-09-20 19:22:30 -04:00
|
|
|
module ActiveRecord #:nodoc:
|
2010-06-16 13:52:35 -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)
|
2010-08-29 10:10:31 -04:00
|
|
|
options = options.try(:clone) || {}
|
2009-08-13 23:27:09 -04:00
|
|
|
|
2012-01-05 22:53:29 -05:00
|
|
|
options[:except] = Array(options[:except]).map { |n| n.to_s }
|
|
|
|
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
|
|
|
|
|
|
|
|
require 'active_record/serializers/xml_serializer'
|