0

Hi my application is already way too complicated to add some analytics code in it.

I really want to design special classes that will allow me to insert some AOP pointcuts (that will trigger some mixpanel).

I do not want to use a gem, only pure ruby. With modules, concerns, metaprogramming and whatnot.

Using just the callback before, around, after is not enough I would like to cut in a conditional for instance.

Any idea? Thanks

rolele
  • 781
  • 9
  • 24
  • What do you mean by "no gem"? You want someone to give you a full analytics solution from scratch? In here? – Uri Agassi Nov 25 '14 at 20:29
  • no. forget about the analytic part. I just want to have special classes that insert code in my application at some specific points. – rolele Nov 25 '14 at 20:34
  • An obvious approach is to use `alias_method` to hide the original method that is being instrumented and replace with dynamically generated instrumenting wrapper. Although it is only marginally cleaner than using plain `around_action`. – Sergio Tulentsev Nov 25 '14 at 20:37
  • Ok your solution is good. But imagine that my controller render html and json (it is just 1 method). Is it possible to say "run some code before render html" "run some other code before render json" From the outside – rolele Nov 25 '14 at 20:47
  • @pierolele: everything is possible, given enough effort. :) – Sergio Tulentsev Nov 25 '14 at 21:20

0 Answers0