Let's say I have a function called bla
defined somewhere in my rails app.
Is there a way in ruby or rails through which I can print the code dynamically/programmatically used to define that function ? So for example:
def bla
puts "Hi There"
end
and then if I call a function like, for example, get_definition
:
puts get_definition(:bla)
this would print out
"puts \"Hi There\""
Is there a canonical way of doing this ? I haven't actually needed to do this before, and I know this is not really common practice in rails.
I also don't want to define my method using meta (reflective) programming and then store the string used to define my method. Any help is appreciated!