In my Rails application, Strings have gotten smart enough to compare themselves to dates:
$ rails console
Loading development environment (Rails 5.2.4.2)
2.6.6 :001 > '2020-01-01' < Time.now
=> true
whereas in regular irb, this fails:
2.6.6 :001 > '2020-01-01' < Time.now
Traceback (most recent call last):
8: from /usr/share/rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:22:in `<main>'
7: from /usr/share/rvm/gems/ruby-2.6.6/bin/ruby_executable_hooks:22:in `eval'
6: from /usr/share/rvm/rubies/ruby-2.6.6/bin/irb:23:in `<main>'
5: from /usr/share/rvm/rubies/ruby-2.6.6/bin/irb:23:in `load'
4: from /usr/share/rvm/rubies/ruby-2.6.6/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
3: from (irb):6
2: from (irb):6:in `rescue in irb_binding'
1: from (irb):6:in `<'
ArgumentError (comparison of String with Time failed)
I have some concerns about how this is implemented, but I have no idea where to look. I have tried the following:
- looking in
config/initializers
- searching the entire repo for
(class|module) str
(regex, case-insensitive) - searching the entire repo for
comparable
(presuming it was something to do with the Comparable module.
I suspect it's being brought in by some gem, but I don't know how to narrow it down. Any advice is welcome.