class DearInventory::Environment

Constants

ENVIRONMENTS

Public Class Methods

production?() click to toggle source
# File lib/dear_inventory/environment.rb, line 9
def production?
  to_sym == :production
end
set(value) click to toggle source
# File lib/dear_inventory/environment.rb, line 23
def set(value)
  return @to_sym = value if ENVIRONMENTS.include?(value)

  error_value = value.is_a?(Symbol) ? ":#{value}" : value.to_s
  raise(
    ArgumentError,
    "#{error_value} is not an acceptable environment; " \
      "please use either :production or :test"
  )
end
test?() click to toggle source
# File lib/dear_inventory/environment.rb, line 13
def test?
  to_sym == :test
end
to_sym() click to toggle source
# File lib/dear_inventory/environment.rb, line 17
def to_sym
  @to_sym ||= set(default)
end

Private Class Methods

default() click to toggle source
# File lib/dear_inventory/environment.rb, line 36
def default
  return :test if ENV["ENV"] == "test"
  return rails if rails?

  :production
end
rails() click to toggle source
# File lib/dear_inventory/environment.rb, line 47
def rails
  return :production if Rails.env.production?

  :test
end
rails?() click to toggle source
# File lib/dear_inventory/environment.rb, line 43
def rails?
  defined?(Rails)
end