Class: Og::KirbyStore
Overview
A Store that persists objects into an KirbyBase database. KirbyBase is a pure-ruby database implementation. To read documentation about the methods, consult the documentation for SqlStore and Store.
Instance Attribute Summary
Attributes inherited from SqlStore
#conn
Attributes inherited from Store
#options, #transaction_nesting
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from SqlStore
#count, #enable_logging, #find, #find_one, #join, #load, #reload, #unjoin, #update, #update_properties
Methods included from SqlUtils
#date, #escape, #join_table, #parse_date, #parse_float, #parse_int, #parse_timestamp, #quote, #table, #timestamp
Methods inherited from Store
#count, create, #delete, #find, for_name, #insert, #load, #reload, #save, #transaction, #update, #update_properties
Constructor Details
#initialize(options) ⇒ KirbyStore
Returns a new instance of KirbyStore.
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/og/store/kirby.rb', line 32
def initialize(options)
super
if options[:embedded]
name = self.class.db_dir(options)
FileUtils.mkdir_p(name)
@conn = KirbyBase.new(:local, nil, nil, name)
else
end
end
|
Class Method Details
.db_dir(options) ⇒ Object
19
20
21
|
# File 'lib/og/store/kirby.rb', line 19
def self.db_dir(options)
"#{options[:name]}_db"
end
|
.destroy(options) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/og/store/kirby.rb', line 23
def self.destroy(options)
begin
FileUtils.rm_rf(db_dir(options))
super
rescue Object
Logger.info "Cannot drop '#{options[:name]}'!"
end
end
|
Instance Method Details
#close ⇒ Object
44
45
46
|
# File 'lib/og/store/kirby.rb', line 44
def close
super
end
|
#commit ⇒ Object
71
72
73
|
# File 'lib/og/store/kirby.rb', line 71
def commit
end
|
#enchant(klass, manager) ⇒ Object
48
49
50
51
|
# File 'lib/og/store/kirby.rb', line 48
def enchant(klass, manager)
klass.property :oid, Fixnum, :sql => 'integer PRIMARY KEY'
super
end
|
#exec(sql) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/og/store/kirby.rb', line 60
def exec(sql)
Logger.debug sql if $DBG
@conn.query(sql).close
rescue => ex
handle_sql_exception(ex, sql)
end
|
#query(sql) ⇒ Object
53
54
55
56
57
58
|
# File 'lib/og/store/kirby.rb', line 53
def query(sql)
Logger.debug sql if $DBG
return @conn.query(sql)
rescue => ex
handle_sql_exception(ex, sql)
end
|
#rollback ⇒ Object
75
76
77
|
# File 'lib/og/store/kirby.rb', line 75
def rollback
end
|
#start ⇒ Object
67
68
69
|
# File 'lib/og/store/kirby.rb', line 67
def start
end
|