class Tynn # Public: Adds helper methods to get and check the current environment. # # Examples # # 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"]`. # # Examples # # Tynn.helpers(Tynn::Environment, env: ENV["RACK_ENV"]) # module Environment def self.setup(app, env: ENV["RACK_ENV"]) # :nodoc: app.set(: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 end