I have:
# lib/freedom_patches/html_safe.rb
class String
alias_method :dangerously_output_as_html, :html_safe
end
Searching the method name dangerously_output_as_html
in the codebase works but wondering is there a programmatic way to find out where this alias is?
"".method(:dangerously_output_as_html).source_location
brought me to the html_safe
location:
activesupport/lib/active_support/core_ext/string/output_safety.rb
instead of where the monkey patch is:
lib/freedom_patches/html_safe.rb
Thanks in advance.
I do not believe there is a way to arrive at the location where alias_method
is used to define a method; I believe that under the hood at the C level, they share the same internal representation of a method. My grasp of the C code is far from complete, so I could be mistaken.
Instead, you may way to use
def dangerously_output_as_html
html_safe
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With