Class: Convergence::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/convergence/config.rb

Constant Summary collapse

ATTRIBUTES =
%i[adapter database host port username password].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Config

Returns a new instance of Config.



9
10
11
12
13
14
15
# File 'lib/convergence/config.rb', line 9

def initialize(attributes)
  attributes.each do |k, v|
    next if v.nil?
    next if !ATTRIBUTES.include?(k.to_sym) && !ATTRIBUTES.include?(k.to_s)
    instance_variable_set("@#{k}", v)
  end
end

Class Method Details

.load(yaml_path) ⇒ Object



17
18
19
20
# File 'lib/convergence/config.rb', line 17

def self.load(yaml_path)
  setting = YAML.safe_load(ERB.new(File.read(yaml_path)).result, [], [], true)
  new(setting)
end