Sha256: b6d59ca896639242edc763284b6bf9c73890622e7bfc7452558e32c22de1e594
Contents?: true
Size: 867 Bytes
Versions: 1
Compression:
Stored size: 867 Bytes
Contents
# frozen_string_literal: true module ActiveSupport # Wrapping a string in this class gives you a prettier way to test # for equality. The value returned by <tt>Quails.env</tt> is wrapped # in a StringInquirer object, so instead of calling this: # # Quails.env == 'production' # # you can call this: # # Quails.env.production? # # == Instantiating a new StringInquirer # # vehicle = ActiveSupport::StringInquirer.new('car') # vehicle.car? # => true # vehicle.bike? # => false class StringInquirer < String private def respond_to_missing?(method_name, include_private = false) (method_name[-1] == "?") || super end def method_missing(method_name, *arguments) if method_name[-1] == "?" self == method_name[0..-2] else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-on-quails-0.1.0 | activesupport/lib/active_support/string_inquirer.rb |