Class: Volt::Environment
Instance Method Summary collapse
- #==(val) ⇒ Object
- #development? ⇒ Boolean
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
- #inspect ⇒ Object
- #production? ⇒ Boolean
- #test? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Method Details
#==(val) ⇒ Object
19 20 21 |
# File 'lib/volt/volt/environment.rb', line 19 def ==(val) @env == val end |
#development? ⇒ Boolean
31 32 33 |
# File 'lib/volt/volt/environment.rb', line 31 def development? self.==('development') end |
#inspect ⇒ Object
35 36 37 |
# File 'lib/volt/volt/environment.rb', line 35 def inspect @env.inspect end |
#production? ⇒ Boolean
23 24 25 |
# File 'lib/volt/volt/environment.rb', line 23 def production? self.==('production') end |
#test? ⇒ Boolean
27 28 29 |
# File 'lib/volt/volt/environment.rb', line 27 def test? self.==('test') end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/volt/volt/environment.rb', line 39 def to_s @env end |