Module: Waxx::Conf

Extended by:
Conf
Included in:
Conf
Defined in:
waxx/conf.rb

Overview

The global Waxx::Conf variable. ex: `Waxx::Conf['name']` or shortcut `Waxx['name']` Data is set in opt/env/config.yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject (readonly)

Internal class var for conf data



24
25
26
# File 'waxx/conf.rb', line 24

def data
  @data
end

Instance Method Details

#/(n) ⇒ Object

Get a Waxx variable



49
50
51
# File 'waxx/conf.rb', line 49

def /(n)
  @data[n.to_s] || @data[n.to_sym]
end

#[](n) ⇒ Object

Get a Waxx variable



37
38
39
# File 'waxx/conf.rb', line 37

def [](n)
  @data[n]
end

#[]=(n, v) ⇒ Object

Set a conf variable



43
44
45
# File 'waxx/conf.rb', line 43

def []=(n, v)
  @data[n] = v
end

#load_yaml(base = ENV['PWD'], env = "active") ⇒ Object

Load the yaml config file into the Waxx module Access variables with Waxx['var2'] or Waxx/:var1/:var2



30
31
32
33
# File 'waxx/conf.rb', line 30

def load_yaml(base=ENV['PWD'], env="active")
  env = "dev" if env == "active" and not File.exist? "#{base}/opt/active"
  @data = ::YAML.load_file("#{base}/opt/#{env}/config.yaml")
end