Get your filthy hands off my Kernel methods
Using pre-existing libraries can save you development time. Unfortunately, the quality of Ruby plugins and gems can be highly variable.
Kernel#__method__
as defined in the
aws-s3
gem:
unless (RUBY_VERSION[0,3] == '1.9') module Kernel def __method__ /\`([^\']+)\'/.match(caller(1).first)[1].to_sym end # ... end end
Kernel#__method__
as defined in the
facets
gem:
module Kernel def __method__(depth = 0) caller[depth][/`([^']+)'/, 1] end if RUBY_VERSION <= '1.8.7' # ... end
Can you guess what happens when both are loaded?
One definition wins. Something breaks.
So which one is right?
Neither.
Please don’t write code like this.