lib/tynn/environment.rb in tynn-1.0.0.rc1 vs lib/tynn/environment.rb in tynn-1.0.0.rc2

- old
+ new

@@ -1,44 +1,46 @@ -# 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] +class Tynn + # 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 Environment + def self.setup(app, env: ENV["RACK_ENV"]) # :nodoc: + app.set(:environment, (env || :development).to_sym) end - def development? - return environment == :development - end + module ClassMethods # :nodoc: + def environment + return settings[:environment] + end - def test? - return environment == :test - end + def development? + return environment == :development + end - def production? - return environment == :production + def test? + return environment == :test + end + + def production? + return environment == :production + end end end end