Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Created August 12, 2021 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobinDaugherty/68deca9dccb22a01b527aa89bd042cb5 to your computer and use it in GitHub Desktop.
Save RobinDaugherty/68deca9dccb22a01b527aa89bd042cb5 to your computer and use it in GitHub Desktop.
# 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