Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonatasemidio/11ca438c34503cb1c20a to your computer and use it in GitHub Desktop.
Save jonatasemidio/11ca438c34503cb1c20a to your computer and use it in GitHub Desktop.
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