Sha256: 4a809b5ede315c97b0be63d6ad07173b5c5dacdec572fbce245a982d8c4f5810
Contents?: true
Size: 888 Bytes
Versions: 2
Compression:
Stored size: 888 Bytes
Contents
# Adds helper methods to get and check the current environment. # # require "tynn" # require "tynn/environment" # # Tynn.helpers(Tynn::Environment) # # Tynn.environment # => :development # # Tynn.development? # => true # Tynn.production? # => false # Tynn.test? # => false # # By default, the environment is based on `ENV["RACK_ENV"]`. # # Tynn.helpers(Tynn::Environment, env: ENV["RACK_ENV"]) # module Tynn::Environment def self.setup(app, env: ENV["RACK_ENV"]) # :nodoc: app.settings[:environment] = (env || :development).to_sym end module ClassMethods # :nodoc: def environment return settings[:environment] end def development? return environment == :development end def test? return environment == :test end def production? return environment == :production end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tynn-0.0.4 | lib/tynn/environment.rb |
tynn-0.0.3 | lib/tynn/environment.rb |