Class: ODDB::Config

Inherits:
Object show all
Includes:
Persistence
Defined in:
src/util/config.rb

Constant Summary

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Method Summary (collapse)

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (Config) initialize

A new instance of Config



9
10
11
# File 'src/util/config.rb', line 9

def initialize
  @values = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(method, *args)



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'src/util/config.rb', line 12

def method_missing(method, *args)
  if(@values.odba_instance.nil?)
    @values = {}
  end
  key = method.to_s
  if(match = /^create_(.*)$/.match(key))
    @values[match[1]] ||= Config.new
    @values.odba_store
    odba_store
  elsif(match = /^(.*)=$/.match(key))
    old = @values[match[1]]
    ret = @values[match[1]] = args.first
    ret.odba_isolated_store
    @values.odba_isolated_store
    odba_store
    if(old.respond_to?(:odba_delete) && !old.eql?(ret))
      old.odba_delete
    end
    ret
  else
    @values[key]
  end
end

Instance Method Details

- (Object) method(mth)



35
36
37
38
39
# File 'src/util/config.rb', line 35

def method(mth)
  Proc.new {
    @values[mth.to_s]
  }
end

- (Boolean) respond_to?(mth)

Returns:

  • (Boolean)


40
41
42
# File 'src/util/config.rb', line 40

def respond_to?(mth)
  !%w{marshal_dump _dump marshal_load _load}.include?(mth.to_s)
end