0xjmp / ObjectMapper-Realm

An ObjectMapper extension that serializes arbitrary JSON into Realm's List class
Other
178 stars 43 forks source link

ImmutableMappable support #20

Closed jfredsilva closed 6 years ago

jfredsilva commented 7 years ago

Do you plan on adding support for ImmutableMappable?

0xjmp commented 6 years ago

@jfredsilva I was finally able to get around to checking this out. Unless I'm mistaken, it seems that ObjectMapper+Realm already supports ImmutableMappable:

class User: Object, ImmutableMappable {
    dynamic var username: NSString?
    var friends: List<User>?

    required convenience init(map: Map) throws {
        self.init()
    }

    override class func primaryKey() -> String? {
        return "username"
    }

    func mapping(map: Map) {
        username              <- map["username"]
        friends               <- (map["friends"], ListTransform<User>())
    }
}