JSONApi part1

This commit is contained in:
2015-09-02 15:52:48 +02:00
parent 5d1ecd81c8
commit f47a8a9ed0
51 changed files with 386 additions and 141 deletions
+22
View File
@@ -1,7 +1,14 @@
module Qwaiter
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)
@@ -10,6 +17,21 @@ module Qwaiter
#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