Created
August 12, 2021 14:16
-
-
Save RobinDaugherty/68deca9dccb22a01b527aa89bd042cb5 to your computer and use it in GitHub Desktop.
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
# frozen_string_literal: true | |
class ApplicationEnvironment | |
def initialize(rails_env:, application_env:) | |
@name = if rails_env == 'test' | |
:test | |
elsif rails_env == 'development' | |
:development | |
elsif rails_env == 'staging' || (rails_env == 'production' && application_env == 'staging') | |
:staging | |
elsif rails_env == 'demo' || (rails_env == 'production' && application_env == 'demo') | |
:demo | |
else | |
:production | |
end | |
end | |
def test? | |
name == :test | |
end | |
def development? | |
name == :development | |
end | |
def production? | |
name == :production | |
end | |
def staging? | |
name == :staging | |
end | |
def demo? | |
name == :demo | |
end | |
attr_reader :name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment