module Crystal::Environment
Overview
require "crystal-environment"
Crystal.env.name # => "development"
Crystal.env.development? # => true
Crystal.env.production? # => false
Extended Modules
Defined in:
crystal-environment/environment.crcrystal-environment/version.cr
Constant Summary
-
DEFAULT =
"development" -
Default value used when
ENV["CRYSTAL_ENV"]?isnil. -
KEY =
"CRYSTAL_ENV" -
Environment variable name used to set the current environment
#name. -
VALUES =
Set {"development", "test", "production"} -
Default
Setof environments. -
VERSION =
"0.1.0"
Macro Summary
-
setup(keys)
Appends given keys to the list of known environments.
Instance Method Summary
-
#development?
Returns
trueif#nameequals"development",falseotherwise. -
#name : String
Returns value of
ENV["CRYSTAL_ENV"]?if any,"development"otherwise. -
#name=(name : String | Symbol | Nil) : String | Nil
Sets
ENV["CRYSTAL_ENV"]?to the given name or unsets it, when passednil. -
#production?
Returns
trueif#nameequals"production",falseotherwise. -
#test?
Returns
trueif#nameequals"test",falseotherwise.
Macro Detail
macro setup(keys)
#
Appends given keys to the list of known environments. For every key, a query method will be created:
Crystal::Environment.setup %w(foo bar)
typeof(Crystal.env.foo?) # => Bool
typeof(Crystal.env.bar?) # => Bool
NOTE development, test and production will always be defined.
Instance Method Detail
def name=(name : String | Symbol | Nil) : String | Nil
#
Sets ENV["CRYSTAL_ENV"]? to the given name or unsets it, when passed nil.