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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en.