Forked from biancarosa/domainsAndInterfaces.groovy
Last active
August 29, 2015 14:24
-
-
Save jonatasemidio/11ca438c34503cb1c20a to your computer and use it in GitHub Desktop.
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
interface Buyable { | |
def buy() | |
} | |
class SomeBuyableObject implements Buyable { | |
String foo | |
def buy() { //do stuff } | |
} | |
class AnotherBuyableObject implements Buyable { | |
String bar | |
def buy() { //do stuff } | |
} | |
class MyService { | |
def listBuyables() { | |
def s = new SomeBuyableObject(foo: 'foo').save() | |
def a = new AnotherBuyableObject(bar : 'bar').save() | |
def buyables = [s, a]*.findAll().sum() // GORM find all | |
assert buyables.size() == 2 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment