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 18 19 |
# 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" when String raise ArgumentError.new("'#{string_value}' is not a valid project environment") else raise ArgumentError.new("'#{string_value.class}' cannot be used as a project environment") end end |
Instance Method Details
#development? ⇒ true|false
Returns true is this is development.
22 23 |
# File 'lib/brut/framework/project_environment.rb', line 22 def development? = @value == "development" # @return [true|false] true is this is test |
#production? ⇒ true|false
Returns true is this is production.
26 |
# File 'lib/brut/framework/project_environment.rb', line 26 def production? = @value == "production" |
#staging? ⇒ Boolean
28 |
# File 'lib/brut/framework/project_environment.rb', line 28 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.
24 25 |
# File 'lib/brut/framework/project_environment.rb', line 24 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).
31 |
# File 'lib/brut/framework/project_environment.rb', line 31 def to_s = @value |