As I mentioned before, I was planning to make some breaking changes to lift-record, and since I got no additional feedback, I've now pushed to master.
These changes make some cleanups to method naming and functionality in lift-record, and all code using 2.0-SNAPSHOT will need some changes: - Each MetaRecord implementation must define createRecord. To migrate, add this method to your MetaRecord: def createRecord: MyRecord = new MyRecord - If you previously used Record#fromJSON, you will need to use Record#setFieldsFromJSON instead. - If you previously used MetaRecord#createRecord(json: String), you will need to use MetaRecord#fromJSON instead. - If you previously used MetaRecord#fromJSON(inst, json), you will need to use MetaRecord#setFieldsFromJSON instead. In addition, lift-couchdb has been updated to track these changes: - If you previously used JSONRecord#fromJValue, you will need to use JSONRecord#setFieldsFromJValue instead. - If you previously used JSONMetaRecord#fromJValue(rec, jvalue), you will need to use JSONMetaRecord#setFieldsFromJValue instead. - CouchMetaRecord#create and CouchMetaRecord#createFromJValue have been removed. Use MetaRecord#createRecord and JSONMetaRecord#fromJValue instead. Let me know if anyone has any problems. -Ross On Feb 27, 2010, at 11:53 AM, Ross Mellgren wrote: > Hey all, > > So as a result of an infelicity in the way records are initialized that > tripped up Tim a week or two ago, I'm planning on doing some cleanup to > lift-record. It is a breaking change, and it was noted that it'd be good to > get opinions on this, so here we are! > > The original problem was that if you used "new MyRecord" then you'd get a > record that was basically functional but some of the extended metadata > (notably field.name) would not be initialized correctly. This is because the > correct way to create a record was MyRecordMeta.createRecord. > > I fixed it so that new MyRecord is equivalent to MyRecordMeta.createRecord, > but Marius pointed out there was more cleaning to do. > > Here are the changes: > - I made the createRecord method on MetaRecord abstract, so that MyRecordMeta > must now implement it. If you are porting over old code, then just do: > def createRecord = new MyRecord > This change is so that record creation must be explicitly specified in case > it is different from new MyRecord (the default implementation) > > - MetaRecord.fromJSON(inst, json) has been renamed to setFieldsFromJSON(inst, > json) > - a new method MetaRecord.setFieldsFromReq(inst, req) has been created to > parallel the new name of fromJSON > - MetaRecord.createRecord(json) has been renamed to fromJSON(json) > - Record.fromJSON has been renamed to setFieldsFromJSON > - Record.setFieldsFromReq has been added -- they just call the meta methods > of the same name. > > These changes at the end make it so that fromSomething(something) are > consistently factory methods that create records from some source (JSON or > Req), and that setFieldsFromSomething(inst, something) is consistently there > for setting the fields from the source. > > Let me know what you think. > > -Ross > > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.