Class: Envvy::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/envvy/engine.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.config_pathObject

Returns the value of attribute config_path.



8
9
10
# File 'lib/envvy/engine.rb', line 8

def config_path
  @config_path
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



5
6
7
# File 'lib/envvy/engine.rb', line 5

def env
  @env
end

Instance Method Details

#get(key, &block) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/envvy/engine.rb', line 61

def get(key, &block)
  if block_given?
    yield self.env[key]
  else
    return self.env[key]
  end
end

#set_env(file) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/envvy/engine.rb', line 52

def set_env file
  self.env = {"js_config" => {}, "config" => {}}
  self.env.merge! YAML.load(File.read(file)) if File.exist?(file)

  if env[Rails.env]
    self.env.deep_merge!(self.env[Rails.env])
  end
end