class Volt::Environment

Public Class Methods

new() click to toggle source
# File lib/volt/volt/environment.rb, line 3
def initialize
  # Use VOLT_ENV or RACK_ENV to set the environment
  @env = ENV['VOLT_ENV'] || ENV['RACK_ENV']

  # If we're in opal, we can set the env from JS before opal loads
  if RUBY_PLATFORM == 'opal'
    unless @env
      `if (window.start_env) {`
      @env = `window.start_env`
      `}`
    end
  end

  @env ||= 'development'
end

Public Instance Methods

==(val) click to toggle source
# File lib/volt/volt/environment.rb, line 19
def ==(val)
  @env == val
end
development?() click to toggle source
# File lib/volt/volt/environment.rb, line 31
def development?
  self.==('development')
end
inspect() click to toggle source
# File lib/volt/volt/environment.rb, line 35
def inspect
  @env.inspect
end
production?() click to toggle source
# File lib/volt/volt/environment.rb, line 23
def production?
  self.==('production')
end
test?() click to toggle source
# File lib/volt/volt/environment.rb, line 27
def test?
  self.==('test')
end
to_s() click to toggle source
# File lib/volt/volt/environment.rb, line 39
def to_s
  @env
end