Let's say I have a function called bla defined somewhere in my rails application.
Is there a way in ruby ββor rails through which I can print the code dynamically / programmatically used to define this function? For example:
def bla puts "Hi There" end
and then if I call a function, for example, get_definition :
puts get_definition(:bla)
it will print
"puts \"Hi There\""
Is there a canonical way to do this? I really did not need to do this before, and I know that this is not a common practice in rails.
I also do not want to define my method using meta-reflexive programming, and then store the string used to define my method. Any help is appreciated!
source share