Paul
Groves
Ltd

StringInquirer

The ActiveSupport::StringInquirer class provides a clean and tidy means to test for string equality, it's what makes Rails.env.production? work.

Here is a simple example, where a pseudo API service class returns a status string:

class SomeApiService

  def status
    api_fetch_status_string.inquiry
  end

end

Now, rather writing code like if status == "approved", you can go for the simpler and cleaner:

response = SomeApiService.new

if response.status.approved?
  "Yay! - all good"
end