Wrapped Rails.env in StringQuestioneer so you can do Rails.env.development? [DHH]

上级 7cfa6ec8
......@@ -4,6 +4,8 @@
* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ActiveSupport [Josh Peek]
* Added StringQuestioneer for doing things like StringQuestioneer.new("production").production? # => true and StringQuestioneer.new("production").development? # => false [DHH]
* Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger)
......
......@@ -43,6 +43,8 @@
require 'active_support/ordered_options'
require 'active_support/option_merger'
require 'active_support/string_questioneer'
require 'active_support/values/time_zone'
require 'active_support/duration'
......
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
\ No newline at end of file
require 'abstract_unit'
class StringQuestioneerTest < Test::Unit::TestCase
def test_match
assert StringQuestioneer.new("production").production?
end
def test_miss
assert !StringQuestioneer.new("production").development?
end
def test_missing_question_mark
assert_raises(NoMethodError) { StringQuestioneer.new("production").production }
end
end
\ No newline at end of file
*Edge*
* Wrapped Rails.env in StringQuestioneer so you can do Rails.env.development? [DHH]
* Fixed that RailsInfoController wasn't considering all requests local in development mode (Edgard Castro) [#310 state:resolved]
......
......@@ -37,7 +37,7 @@ def root
end
def env
RAILS_ENV
StringQuestioneer.new(RAILS_ENV)
end
def cache
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册