class Ops::Config

Public Class Methods

new(data = {}) click to toggle source
# File lib/ops/config.rb, line 3
def initialize(data = {})
  @data = {}
  update!(data)
end

Public Instance Methods

[](key) click to toggle source
# File lib/ops/config.rb, line 14
def [](key)
  @data[key.to_sym]
end
[]=(key, value) click to toggle source
# File lib/ops/config.rb, line 18
def []=(key, value)
  @data[key.to_sym] = if value.class == Hash
                        Config.new(value)
                      else
                        value
                      end
end
method_missing(sym, *args) click to toggle source
# File lib/ops/config.rb, line 26
def method_missing(sym, *args) # rubocop:disable Style/MethodMissing
  if sym.to_s =~ /(.+)=$/
    self[Regexp.last_match(1)] = args.first
  else
    self[sym]
  end
end
update!(data) click to toggle source
# File lib/ops/config.rb, line 8
def update!(data)
  data.each do |key, value|
    self[key] = value
  end
end