Created
January 28, 2014 18:36
-
-
Save atomsfat/8673440 to your computer and use it in GitHub Desktop.
Fat grails domain class with custom marshaller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package atoms.fat.media | |
import grails.converters.JSON | |
import org.joda.time.DateTime | |
class Media implements Serializable { | |
String url | |
String name | |
DateTime dateCreated | |
DateTime lastUpdated | |
static constraints = { | |
url blank: false, url: true, maxSize: 500 | |
name nullable: true, mazSize: 100 | |
dateCreated display: false, nullable: true | |
lastUpdated display: false, nullable: true | |
} | |
//here custom marshaller | |
static marshaller = { | |
JSON.registerObjectMarshaller(Media, 1) { m -> | |
return [ | |
id: m.id, | |
url: m.url, | |
name: m.name | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment