Module: SimpleConf

Defined in:
lib/simpleconf.rb,
lib/simpleconf/conf.rb,
lib/simpleconf/version.rb

Defined Under Namespace

Classes: Conf

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.build(opts = {}, &blk) ⇒ Object



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

def build(opts={}, &blk)
  fail "Build needs a block" unless block_given?
  c = Conf.new(blk, opts)
  c.instance_eval(&blk)
  c.__init_only__ = true if opts[:init_only]
  c
end

.build_from_string(instance_str, opts = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/simpleconf.rb', line 16

def build_from_string(instance_str, opts={})
  c = Conf.new(instance_str, opts)
  c.instance_eval(instance_str)
  c.__init_only__ = true if opts[:init_only]
  c
end

.load(file_name, opts = {}) ⇒ Object



23
24
25
# File 'lib/simpleconf.rb', line 23

def load(file_name, opts={})
  build_from_string(File.read(file_name), opts)
end