Metro 0.2 Released

2008 December 19
tags: Metro · Transfer
by Paul Marcotte
The latest release (0.2) of Metro eliminates a convention on naming object Ids (or your database table Primary Key). Like a lot of developers, I tend to name my table PK as table name plus "Id" - UserId, AddressId, etc. I used this convention within the core Service for Metro, but I was unsatisfied with that limitation. Using Metro should not force one to adopt another developers convention(s). So I re-factored the core Service and Gateway to use Transfer metadata instead. Object retrieval in the Service save() method which looked like this: <cfset var obj = get(arguments.objectName,arguments.input[arguments.objectName&"Id"])> Is now this: <cfset var pkName = getGateway(arguments.objectName).getPrimaryKey()>
<cfset var obj = get(arguments.objectName,arguments.input[pkName])>
And the core Gateway has this new method. <cffunction name="getPrimaryKey" access="public" output="false" returntype="string">
<cfreturn getTransfer().getTransferMetadata(getClassName()).getPrimaryKey().getName()>
These are small but important changes to the Metro library.