Module: Configur

Defined in:
lib/configur.rb

Overview

Configur module

Constant Summary collapse

VERSION =

Version constant

[1, 1, 0].join '.'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_config(oid, name, value) ⇒ Object

Set a config value



38
39
40
41
# File 'lib/configur.rb', line 38

def self.set_config(oid, name, value)
  @@_cdata[oid] ||= {}
  @@_cdata[oid][name.to_sym] = value
end

Instance Method Details

#configur {|block| ... } ⇒ Object

Configur

Yields:

  • (block)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/configur.rb', line 14

def configur(&block)
  @@_cdata ||= {}
  @@_oid = self.object_id

  def block.method_missing(m, *args, &block)
    name = m.to_s
    super if name[-1] != '='
    Configur.set_config @@_oid, name.gsub('=', ''), args[0]
  end

  yield block
end

#get_config(name) ⇒ Object

Get a config value



33
34
35
# File 'lib/configur.rb', line 33

def get_config(name)
  @@_cdata[self.object_id][name.to_sym] || nil
end

#get_configsObject

Get all configs



28
29
30
# File 'lib/configur.rb', line 28

def get_configs
  @@_cdata[self.object_id] || {}
end