Sha256: cb01c19f6bf1b3bb8ff8626862cc1fc99fadc862944d783794a725a4fe50c18f

Contents?: true

Size: 717 Bytes

Versions: 44

Compression:

Stored size: 717 Bytes

Contents

module Volt
  class Environment
    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

    def ==(val)
      @env == val
    end

    def production?
      self.==('production')
    end

    def test?
      self.==('test')
    end

    def development?
      self.==('development')
    end

    def inspect
      @env.inspect
    end

    def to_s
      @env
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
volt-0.9.7.pre2 lib/volt/volt/environment.rb
volt-0.9.6 lib/volt/volt/environment.rb
volt-0.9.6.pre3 lib/volt/volt/environment.rb
volt-0.9.6.pre2 lib/volt/volt/environment.rb
volt-0.9.6.pre1 lib/volt/volt/environment.rb
volt-0.9.5 lib/volt/volt/environment.rb
volt-0.9.5.pre12 lib/volt/volt/environment.rb
volt-0.9.5.pre11 lib/volt/volt/environment.rb
volt-0.9.5.pre9 lib/volt/volt/environment.rb
volt-0.9.5.pre8 lib/volt/volt/environment.rb
volt-0.9.5.pre7 lib/volt/volt/environment.rb
volt-0.9.5.pre6 lib/volt/volt/environment.rb
volt-0.9.5.pre5 lib/volt/volt/environment.rb
volt-0.9.5.pre4 lib/volt/volt/environment.rb
volt-0.9.5.pre3 lib/volt/volt/environment.rb
volt-0.9.5.pre2 lib/volt/volt/environment.rb
volt-0.9.5.pre1 lib/volt/volt/environment.rb
volt-0.9.4 lib/volt/volt/environment.rb
volt-0.9.4.pre5 lib/volt/volt/environment.rb
volt-0.9.4.pre3 lib/volt/volt/environment.rb