Class: KyotoCabinet::Db::PolymorphicDb
- Inherits:
-
Object
- Object
- KyotoCabinet::Db::PolymorphicDb
show all
- Includes:
- KyotoCabinet::Db
- Defined in:
- lib/kyotocabinet_ffi/db/polymorphic_db.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#clear!, #close, #close!, #get, #last_error, #last_error_code, #last_error_message, #new, #open, #open!, #set, #set!, #size
Constructor Details
#initialize(path, options = {}) ⇒ PolymorphicDb
Returns a new instance of PolymorphicDb.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 9
def initialize(path, options = {})
path_s = path.to_s
db_options = options.delete(:db_options) || []
unless KyotoCabinet::match_filedb_type? (path_s) or
KyotoCabinet::match_memorydb_type? (path_s)
msg = %Q{
The path value \"#{path || '(nil)'}\" does not match one of the memory
db types #{KyotoCabinet::MEMORY_DB_TYPE.map(&:to_s).join(', ')} or
one of the file db types #{KyotoCabinet::FILE_DB_TYPE.map(&:to_s).join(', ')}.
}.gsub(%r{^\s+}, ' ').gsub(%r{\n}, '')
fail ArgumentError.new(msg)
end
self.new
self.open!(path, *db_options)
end
|
Class Method Details
.tmp_filedb(type, options = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 26
def self.tmp_filedb(type, options = {})
prefix = options[:prefix]
path = make_temp(type, prefix)
self.new(path, {
:db_options => [:create, :reader, :writer]
})
end
|
Instance Method Details
#[](key) ⇒ Object
35
36
37
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 35
def [](key)
self.get(key)
end
|
#[]=(key, value) ⇒ Object
39
40
41
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 39
def []=(key, value)
self.set(key, value)
end
|
#clear ⇒ Object
47
48
49
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 47
def clear
super
end
|
#empty? ⇒ Boolean
43
44
45
|
# File 'lib/kyotocabinet_ffi/db/polymorphic_db.rb', line 43
def empty?
self.size <= 0
end
|