aboutsummaryrefslogblamecommitdiffstats
path: root/activerecord/lib/active_record/serializers/json_serializer.rb
blob: 8b1b8299f8078dae4ba002a48391cac2d0d21d0d (plain) (tree)
1
2
3

                            
                             














                                                                           
module ActiveRecord #:nodoc:
  module Serialization
    def to_json(options = {})
      JsonSerializer.new(self, options).to_s
    end

    def from_json(json)
      self.attributes = ActiveSupport::JSON.decode(json)
      self
    end

    class JsonSerializer < ActiveRecord::Serialization::Serializer #:nodoc:
      def serialize
        serializable_record.to_json
      end
    end
  end
end