Use regex to match necessary methods
Opened this issue · 1 comments
Hello!
Is there way to point on methods with regex or mask? Example:
after /base/ do |*, team| team.save end
In class i usually have several base methods which names started from certain word ("base_*", for example).
And i wanted use callbacks to my base methods, and not use for others methods.
UPD: It seems like i found a way to do it:
after(self.instance_methods(false).grep(/base/)) do ... end
Hey there!
What you did is exactly what I would have suggested! And I think that's a good way to do it, because this library can't know if you want to include inherited methods or not I think - so I think it's better for the user themselves to do this.
Might be worth a sample or mention in the README though :)
Do you think that's a good enough solution?
Cheers,
Tobi