lib/oneaccess/serializable.rb in oneaccess-0.4.5 vs lib/oneaccess/serializable.rb in oneaccess-0.5.0
- old
+ new
@@ -5,11 +5,23 @@
def represented_by(representer_class)
@representer_class = representer_class
end
def from_json(json)
- obj = new
- @representer_class.new(obj).from_json(json)
- obj
+ if collection?
+ collection = []
+ @representer_class.new(collection).from_json(json)
+ collection
+ else
+ obj = new
+ @representer_class.new(obj).from_json(json)
+ obj
+ end
+ end
+
+ private
+
+ def collection?
+ false
end
end
end