提交 6e85f148 编写于 作者: J Joshua Peek

Namespaced StringQuestioneer under ActiveSupport.

上级 1e4fae42
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
\ No newline at end of file
end
......@@ -2,14 +2,14 @@
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
\ No newline at end of file
......@@ -37,7 +37,7 @@ def root
end
def env
StringQuestioneer.new(RAILS_ENV)
ActiveSupport::StringQuestioneer.new(RAILS_ENV)
end
def cache
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册