class Rackal::Internal::RackEnvironment

Attributes

env[R]

Public Class Methods

new(options = {}) click to toggle source

@api private

# File lib/rackal/internal/rack_environment.rb, line 7
def initialize(options = {})
  @env = (ENV['RACK_ENV'] || 'development').to_sym

  protect_test = options&.fetch(:protect_test, false) || false
  @protect_test = protect_test ? true : false # force boolean
end
supported() click to toggle source

@return Array list of environments recognized as supported by RackEnvironment

# File lib/rackal/internal/rack_environment.rb, line 15
def self.supported
  [:production, :staging, :test, :development]
end

Public Instance Methods

protected() click to toggle source

@return Array list environments treated as protected (e.g., :production)

# File lib/rackal/internal/rack_environment.rb, line 37
def protected
  @protected ||= self.class.supported -
                 (@protect_test ? [:development] : [:development, :test])
end
protected?() click to toggle source

@return Boolean true if current environment is to be treated as protected

# File lib/rackal/internal/rack_environment.rb, line 43
def protected?
  @is_protected ||= protected.include? env
end
supported?() click to toggle source

@return Boolean true if current environment is supported

# File lib/rackal/internal/rack_environment.rb, line 27
def supported?
  @supported ||= self.class.supported.include? env
end
unprotected?() click to toggle source

@return Boolean true if current environment is not to be treated as protected

# File lib/rackal/internal/rack_environment.rb, line 48
def unprotected?
  @is_unprotected ||= !protected?
end
unsupported?() click to toggle source

@return Boolean true if current environment is not supported

# File lib/rackal/internal/rack_environment.rb, line 32
def unsupported?
  !supported?
end