Merge: lib/popcorn: introduce RepoObject in pop_repos
authorJean Privat <jean@pryen.org>
Tue, 16 Aug 2016 17:25:49 +0000 (13:25 -0400)
committerJean Privat <jean@pryen.org>
Tue, 16 Aug 2016 17:25:49 +0000 (13:25 -0400)
### Base serializable entity that can go into a JsonRepository

 Provide boiler plate implementation of all object serializable to json.

`id` is used as a primary key for `find_by_id`.

 Subclassing RepoObject makes it easy to create a serializable class:
 ~~~nit
 import popcorn::pop_repos

 class Album
super RepoObject
serialize

var title: String
var price: Float
 end
 ~~~

 Do not forget the `serialize` annotation else the fields will not be serialized.

 It is also possible to redefine the `id` primary key to use your own:
 ~~~nit
 import popcorn::pop_repos

 class Order
super RepoObject
serialize

redef var id = "order-{get_time}"

# ...

 end
 ~~~

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

Pull-Request: #2265
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge