Class: Bdb::Base
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(opts) ⇒ Base
Returns a new instance of Base.
7
8
9
10
|
# File 'lib/bdb/base.rb', line 7
def initialize(opts)
@config = Bdb::Environment.config.merge(opts)
@indexes = {}
end
|
Instance Attribute Details
Returns the value of attribute indexes.
11
12
13
|
# File 'lib/bdb/base.rb', line 11
def indexes
@indexes
end
|
Instance Method Details
#checkpoint(opts = {}) ⇒ Object
38
39
40
|
# File 'lib/bdb/base.rb', line 38
def checkpoint(opts = {})
environment.checkpoint(opts)
end
|
#config(config = {}) ⇒ Object
13
14
15
|
# File 'lib/bdb/base.rb', line 13
def config(config = {})
@config.merge!(config)
end
|
#environment ⇒ Object
26
27
28
|
# File 'lib/bdb/base.rb', line 26
def environment
@environment ||= Bdb::Environment.new(path, self)
end
|
#index_by(field, opts = {}) ⇒ Object
17
18
19
20
|
# File 'lib/bdb/base.rb', line 17
def index_by(field, opts = {})
raise "index on #{field} already exists" if indexes[field]
indexes[field] = opts
end
|
#master? ⇒ Boolean
42
43
44
|
# File 'lib/bdb/base.rb', line 42
def master?
environment.master?
end
|
22
23
24
|
# File 'lib/bdb/base.rb', line 22
def path
config[:path] || Dir.pwd
end
|
#synchronize(&block) ⇒ Object
34
35
36
|
# File 'lib/bdb/base.rb', line 34
def synchronize(&block)
environment.synchronize(&block)
end
|
#transaction(nested = true, &block) ⇒ Object
30
31
32
|
# File 'lib/bdb/base.rb', line 30
def transaction(nested = true, &block)
environment.transaction(nested, &block)
end
|