Class: Brut::Framework::ProjectEnvironment
- Inherits:
-
Object
- Object
- Brut::Framework::ProjectEnvironment
- Defined in:
- lib/brut/framework/project_environment.rb
Overview
Manages the interpretation of dev/test/prod. The canonical instance is available
via Brut.container.project_env
. Generally, you
should avoid basing logic on this, or at least contain the conditional behavior
to the configuration values. But, you do you.
Instance Method Summary collapse
-
#development? ⇒ true|false
True is this is development.
-
#initialize(string_value) ⇒ ProjectEnvironment
constructor
Create the project environment based on the string.
-
#production? ⇒ true|false
True is this is production.
-
#staging? ⇒ Boolean
-
#test? ⇒ true|false
True is this is test.
-
#to_s ⇒ String
The string value (which should be suitable for the constructor).
Constructor Details
#initialize(string_value) ⇒ ProjectEnvironment
Create the project environment based on the string
9 10 11 12 13 14 15 16 17 |
# File 'lib/brut/framework/project_environment.rb', line 9 def initialize(string_value) @value = case string_value when "development" then "development" when "test" then "test" when "production" then "production" else raise ArgumentError.new("'#{string_value}' is not a valid project environment") end end |
Instance Method Details
#development? ⇒ true|false
Returns true is this is development.
20 21 |
# File 'lib/brut/framework/project_environment.rb', line 20 def development? = @value == "development" # @return [true|false] true is this is test |
#production? ⇒ true|false
Returns true is this is production.
24 |
# File 'lib/brut/framework/project_environment.rb', line 24 def production? = @value == "production" |
#staging? ⇒ Boolean
26 |
# File 'lib/brut/framework/project_environment.rb', line 26 def staging? = raise "Staging is a lie, please consider feature flags or literally any other way to manage in-development features of your app. I promise you, you will regret ever having to do anything with a staging server" |
#test? ⇒ true|false
Returns true is this is test.
22 23 |
# File 'lib/brut/framework/project_environment.rb', line 22 def test? = @value == "test" # @return [true|false] true is this is production |
#to_s ⇒ String
Returns the string value (which should be suitable for the constructor).
29 |
# File 'lib/brut/framework/project_environment.rb', line 29 def to_s = @value |