DRY way to create interceptors in domain object

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

DRY way to create interceptors in domain object

staykov
Hi,
I have a bunch (almost all my domain classes) that require a created,
modified, and some other fields updated on insert/update. What is a good
way to apply the same logic to all my domain classes without copy and
paste?

Thanks!

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DRY way to create interceptors in domain object

bdrhoa
Create an abstract class.
For example, see
https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/IbidemBaseDomain.groovy
https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/Tag.groovy
---------------------------
www.maf.org/rhoads
www.ontherhoads.org


On Wed, Oct 24, 2012 at 2:21 PM,  <[hidden email]> wrote:

> Hi,
> I have a bunch (almost all my domain classes) that require a created,
> modified, and some other fields updated on insert/update. What is a good
> way to apply the same logic to all my domain classes without copy and
> paste?
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DRY way to create interceptors in domain object

bdrhoa
I just noticed that Tag doesn't use the base class anymore. I'm sure
you get the idea. But here's another class that does use it.
https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/Item.groovy

What this brings up is that sometimes the base class doesn't quite
work for certain situations.
---------------------------
www.maf.org/rhoads
www.ontherhoads.org


On Wed, Oct 24, 2012 at 2:29 PM, Brad Rhoads <[hidden email]> wrote:

> Create an abstract class.
> For example, see
> https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/IbidemBaseDomain.groovy
> https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/Tag.groovy
> ---------------------------
> www.maf.org/rhoads
> www.ontherhoads.org
>
>
> On Wed, Oct 24, 2012 at 2:21 PM,  <[hidden email]> wrote:
>> Hi,
>> I have a bunch (almost all my domain classes) that require a created,
>> modified, and some other fields updated on insert/update. What is a good
>> way to apply the same logic to all my domain classes without copy and
>> paste?
>>
>> Thanks!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: DRY way to create interceptors in domain object

sbglasius
Hi,


Another solution would be hooking into the Domain classes via a plugin, but I'm not a 100% sure that it's possible.

Med venlig hilsen / Best regards,
Søren Berg Glasius

Hedevej 1, Gl. Rye, DK-8680 Ry, Denmark
Mobile: (+45)40449188, Skype: sbglasius
--- Press ESC once to quit - twice to save the changes.


2012/10/24 Brad Rhoads <[hidden email]>
I just noticed that Tag doesn't use the base class anymore. I'm sure
you get the idea. But here's another class that does use it.
https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/Item.groovy

What this brings up is that sometimes the base class doesn't quite
work for certain situations.
---------------------------
www.maf.org/rhoads
www.ontherhoads.org


On Wed, Oct 24, 2012 at 2:29 PM, Brad Rhoads <[hidden email]> wrote:
> Create an abstract class.
> For example, see
> https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/IbidemBaseDomain.groovy
> https://trac.maflt.org/web/ibidem/browser/trunk/src/ibidemcore/grails-app/domain/org/maflt/ibidem/Tag.groovy
> ---------------------------
> www.maf.org/rhoads
> www.ontherhoads.org
>
>
> On Wed, Oct 24, 2012 at 2:21 PM,  <[hidden email]> wrote:
>> Hi,
>> I have a bunch (almost all my domain classes) that require a created,
>> modified, and some other fields updated on insert/update. What is a good
>> way to apply the same logic to all my domain classes without copy and
>> paste?
>>
>> Thanks!
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email