1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Namespaced StringQuestioneer under ActiveSupport.

This commit is contained in:
Joshua Peek 2008-06-04 15:02:51 -05:00
parent 1e4fae42d4
commit 6e85f14817
3 changed files with 13 additions and 11 deletions

View file

@ -1,9 +1,11 @@
class StringQuestioneer < String
def method_missing(method_name, *arguments)
if method_name.to_s.ends_with?("?")
self == method_name.to_s[0..-2]
else
super
module ActiveSupport
class StringQuestioneer < String
def method_missing(method_name, *arguments)
if method_name.to_s.ends_with?("?")
self == method_name.to_s[0..-2]
else
super
end
end
end
end
end

View file

@ -2,14 +2,14 @@ require 'abstract_unit'
class StringQuestioneerTest < Test::Unit::TestCase
def test_match
assert StringQuestioneer.new("production").production?
assert ActiveSupport::StringQuestioneer.new("production").production?
end
def test_miss
assert !StringQuestioneer.new("production").development?
assert !ActiveSupport::StringQuestioneer.new("production").development?
end
def test_missing_question_mark
assert_raises(NoMethodError) { StringQuestioneer.new("production").production }
assert_raises(NoMethodError) { ActiveSupport::StringQuestioneer.new("production").production }
end
end

View file

@ -37,7 +37,7 @@ module Rails
end
def env
StringQuestioneer.new(RAILS_ENV)
ActiveSupport::StringQuestioneer.new(RAILS_ENV)
end
def cache