Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrapped Rails.env in StringQuestioneer so you can do Rails.env.develo…
…pment? [DHH]
- Loading branch information
Showing
6 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ def root | |
end | ||
|
||
def env | ||
RAILS_ENV | ||
StringQuestioneer.new(RAILS_ENV) | ||
end | ||
|
||
def cache | ||
|