Files
mozo-backend/lib/mozo/serializer.rb
T
2025-09-20 17:35:58 -05:00

49 lines
987 B
Ruby

=begin
module Mozo
class Serializer < ActiveModel::Serializer
def self.root=(val)
ActiveSupport::Deprecation.new('1.0', 'Mozo')
end
def self.root(val)
ActiveSupport::Deprecation.new('1.0', 'Mozo')
end
# attribute :_id, key: :id
attributes :id, :created_at, :updated_at
# Bug in rails 4.1 serializing symbols in jsonify
#def to_json(*args)
#as_json.to_json(*args)
#end
#def id
#object._id
#end
def created_at
timestamp_attribute :created_at
end
def updated_at
timestamp_attribute :updated_at
end
private
def timestamp_attribute(attr)
timestamp = object.send(attr)
return nil unless timestamp
timestamp.iso8601
end
end
end
=end
# require 'active_model/array_serializer'
# module ActiveModel
# class ArraySerializer
# # Bug in rails 4.1 serializing symbols in jsonify
# def to_json(*args)
# as_json.to_json(*args)
# end
# end
# end