xapian_db 0.5.8 → 0.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +6 -0
- data/lib/xapian_db.rb +9 -7
- metadata +3 -3
data/CHANGELOG.md
CHANGED
data/lib/xapian_db.rb
CHANGED
@@ -88,13 +88,15 @@ module XapianDb
|
|
88
88
|
# Update an object in the index
|
89
89
|
# @param [Object] obj An instance of a class with a blueprint configuration
|
90
90
|
def self.index(obj)
|
91
|
-
@writer
|
91
|
+
writer = @transactional_writer || XapianDb::Config.writer
|
92
|
+
writer.index obj
|
92
93
|
end
|
93
94
|
|
94
95
|
# Remove an object from the index
|
95
96
|
# @param [Object] obj An instance of a class with a blueprint configuration
|
96
97
|
def self.unindex(obj)
|
97
|
-
@writer
|
98
|
+
writer = @transactional_writer || XapianDb::Config.writer
|
99
|
+
writer.unindex obj
|
98
100
|
end
|
99
101
|
|
100
102
|
# Reindex all objects of a given class
|
@@ -102,7 +104,7 @@ module XapianDb
|
|
102
104
|
# @param [Hash] options Options for reindexing
|
103
105
|
# @option options [Boolean] :verbose (false) Should the reindexing give status informations?
|
104
106
|
def self.reindex_class(klass, options={})
|
105
|
-
|
107
|
+
XapianDb::Config.writer.reindex_class klass, options
|
106
108
|
end
|
107
109
|
|
108
110
|
# Rebuild the xapian index for all configured blueprints
|
@@ -121,10 +123,10 @@ module XapianDb
|
|
121
123
|
# Execute a block as a transaction
|
122
124
|
def self.transaction(&block)
|
123
125
|
# Temporarily use the transactional writer
|
124
|
-
@
|
126
|
+
@transactional_writer = XapianDb::IndexWriters::TransactionalWriter.new
|
125
127
|
begin
|
126
128
|
block.call
|
127
|
-
@
|
129
|
+
@transactional_writer.commit_using XapianDb::Config.writer
|
128
130
|
rescue Exception => ex
|
129
131
|
msg = "error in XapianDb transaction block: #{ex}, transaction aborted"
|
130
132
|
if defined?(Rails)
|
@@ -133,8 +135,8 @@ module XapianDb
|
|
133
135
|
puts msg
|
134
136
|
end
|
135
137
|
ensure
|
136
|
-
#
|
137
|
-
@
|
138
|
+
# release the transactional writer
|
139
|
+
@transactional_writer = nil
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 9
|
9
|
+
version: 0.5.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Gernot Kogler
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-03-
|
17
|
+
date: 2011-03-25 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|