Closed aspett closed 6 years ago
This is an interesting question. I think this could be implemented using a decorate_all
attribute:
defmodule Foo do
use MyDecorator
@decorate_all some_function(:foo)
end
Internally I would check for this attribute and decorate all def
s based on it.
This would be very helpful for me. Honestly, I struggle to get my head around this codebase, though.
++
@ludwikbukowski I made progress here: https://github.com/arjan/decorator/pull/16 but it breaks function headers at the moment. Not sure how to fix that yet
@aspett I merged an implementation similar to yours. I believe the issue with function headers will be dealt with in #18, so separate from this.
I'm trying to use this library to decorate every function in a module. My current strategy for doing this is using an
on_definition
hook, andput_attribute
'ing the required parameters. This appears to be working nearly. It has some trouble with multi-clause functions; especially with function headers.After banging my head against this for a few hours, I thought it might just be better to ask if there's an easier way to decorate every function. Thanks!