JSONApi part1
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user