Sha256: 276db8323399a960df6e6e844cc94601b0a3cccfbaa9a11ddc8cbdde96b4ed21

Contents?: true

Size: 642 Bytes

Versions: 22

Compression:

Stored size: 642 Bytes

Contents

module Volt
  class Environment
    def initialize
      @env = ENV['VOLT_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

22 entries across 22 versions & 1 rubygems

Version Path
volt-0.8.17 lib/volt/volt/environment.rb
volt-0.8.16 lib/volt/volt/environment.rb