ActiveSupport is pretty awesome. It has really awesome stuff hidden in it.StringInquirer is one of them.
It lets you test String equality in a much more pretty way. Rails also uses StringInquirer for it’s environment check.
You may recognize this
Instead of doing
Rails.env == 'production'
So how can we use StringInquirer for ourselves.
Let’s pretend that we have a String called status.
status = ActiveSupport::StringInquirer.new 'is_used' status.is_used? # true status.is_new? # false
Happy hacking <3