Sha256: 4a080638898af0ef2b9635b3f576a38069fd9e5a147267d5496f584d59b1c08f
Contents?: true
Size: 927 Bytes
Versions: 4
Compression:
Stored size: 927 Bytes
Contents
require 'active_support/string_inquirer' module BerkeleyLibrary module Logging class << self FALLBACK_ENV = 'development'.freeze ENV_PREDICATES = %i[production? test? development?].freeze private_constant :ENV_PREDICATES def env return Rails.env if defined?(Rails) @env ||= begin # NOTE: can't just self.env= b/c it returns the wrong value -- see # https://stackoverflow.com/q/65226532/27358 env = (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || FALLBACK_ENV) ensure_rails_env_like(env) end end def env=(v) if defined?(Rails) Rails.env = v else @env = ensure_rails_env_like(v) end end private def ensure_rails_env_like(v) return v if ENV_PREDICATES.all? { |p| v.respond_to?(p) } ActiveSupport::StringInquirer.new(v) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems