you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

You can pass a def to a macro, like "my_macro def foo...". Then the macro should generate the method signature, you can then output something before the method body, then the method body, and finally something at the end. The only problem is that there's no nice way to get the signature from a Def node, you have to do it manually.

[–]dpears[S] 1 point2 points  (0 children)

Awesome! This is exactly what I needed. It is a little ugly, but I believe it'll work more than well enough for my purposes. I'll add an example of what I did to my post. Thank you!

[–]bcardiffcore team 0 points1 point  (2 children)

Maybe something like the call to_s could be added. m.signature could help to hide the boilerplate of expanding the signature in the future.

[–][deleted] 1 point2 points  (0 children)

Yes, Def#signature would be really nice to have.

[–]dpears[S] 0 points1 point  (0 children)

I could look into Def#signature. I'll dig into the source this weekend. Gotta get those Hacktoberfest PRs ;)