File: active_support/string_inquirer.rb

Overview
Module Structure
Class Hierarchy
Code

Overview

Module Structure

  module: <Toplevel Module>
  module: ActiveSupport#1
  class: StringInquirer#12
inherits from
  String ( Builtin-Module )
has properties
method: method_missing / 2 #13

Class Hierarchy

Code

   1  module ActiveSupport
   2    # Wrapping a string in this class gives you a prettier way to test
   3    # for equality. The value returned by <tt>Rails.env</tt> is wrapped
   4    # in a StringInquirer object so instead of calling this:
   5    #
   6    #   Rails.env == "production"
   7    #
   8    # you can call this:
   9    #
  10    #   Rails.env.production?
  11    #
  12    class StringInquirer < String
  13      def method_missing(method_name, *arguments)
  14        if method_name.to_s[-1,1] == "?"
  15          self == method_name.to_s[0..-2]
  16        else
  17          super
  18        end
  19      end
  20    end
  21  end