0

I'm familiar with the concept that dynamic methods are added via AOP to domain objects in Grails. But since they're dynamic, how is it that you find the documentation to them?

It wouldn't be obvious where to look for the documentation for these methods even if I knew what Interceptor classes might apply the methods to the domain objects...

Community
  • 1
  • 1
leeand00
  • 25,510
  • 39
  • 140
  • 297
  • Are you sure that grails is using AOP for domain objects? – Igor Artamonov Oct 12 '11 at 03:22
  • @splix Well I guess I'm just kind of assuming really. But when methods show up on a POJO or POGO that aren't coded by you, chances are it's usually a code generation library (cglib) that added the methods. To do that on objects that somebody else wrote you'd need AOP to do so. – leeand00 Oct 12 '11 at 03:33
  • i'm not sure that AOP means 'code generations', btw I asked just as a hint, that it doesn't matter what is used there if you are just looking for a docs – Igor Artamonov Oct 12 '11 at 04:26
  • 1
    No AOP, it's a combination of Groovy metaprogramming and ASTs. – Burt Beckwith Oct 12 '11 at 04:52
  • Thanks Burt! I won't learn a thing if nobody tells me why I'm wrong. – leeand00 Oct 12 '11 at 16:28

2 Answers2

1

Behold the Grails Docs! http://grails.org/doc/latest/ On the right side you have a quick reference that lists among other things dynamic methods added to Domain Classes. It's a good read, enjoy :)

dbrin
  • 15,525
  • 4
  • 56
  • 83
  • I suppose my question was not generalized enough...I figured I would ask so that I could also find the mock object dynamic methods added to a Control Object as well...I know the Grails docs contain these as well, but what of formalized documentation of these methods such as you would find in JavaDocs. I just thought there would be a common method for documenting dynamic methods in general. – leeand00 Oct 12 '11 at 04:28
  • I don't think such a thing exists. Consider how easy it is to add a method to your Class from ANYWHERE in your code: Task.metaClass.isDirty = {} boom! done. What documentation? I am not even sure debugger will show you this stuff - although it should. – dbrin Oct 12 '11 at 04:56
1

There is "Grails Runtime Docs" plugin ( http://grails.org/plugin/grails-runtime-docs ) which will generate the groovy documentation from runtime also including the dynamic methods. It will add "Dynamic Method Summary" & "Dynamic Method Detail" in the generated html docs which provide their source information. The classes are also categorized into Controllers, Commands, Domains, Services and Tag Libraries. Note: I'm a grails developer and contributed this open-source plugin to Grails myself. Hope you find it useful.

Srinath Anantha
  • 108
  • 1
  • 7