Class: JRubySQL::Config

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

Overview

A simple key-value config in YAML

Instance Method Summary collapse

Constructor Details

#initialize(path = JRubySQL::Constants::DEFAULT_RC_PATH) ⇒ Config

Returns a new instance of Config.



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

def initialize path = JRubySQL::Constants::DEFAULT_RC_PATH
  @path = path
  if @path && File.exists?(@path)
    @yaml = YAML.load(File.read(@path))
  end
  @yaml = @yaml || {}
end

Instance Method Details

#[](key) ⇒ Object



16
17
18
# File 'lib/jrubysql/config.rb', line 16

def [] key
  @yaml[key]
end

#[]=(key, value) ⇒ Object



20
21
22
# File 'lib/jrubysql/config.rb', line 20

def []= key, value
  (@yaml[key] = value).tap { dump }
end