public
Description: StrokeDB is an embeddable distributed document database written in Ruby
Homepage: http://strokedb.com/
Clone URL: git://github.com/yrashk/strokedb.git
added meta_initialization proc
oleganza (author)
Tue Apr 29 22:57:51 -0700 2008
commit  8c24572711a8b960f2b61f28e47412475b69e43d
tree    2e5cd6ca68345142973d1c52e0b15524a6240465
parent  3e40ce01088d938ad69041ad6fe6cca51ff61a44
...
8
9
10
11
12
13
14
15
16
17
18
19
 
 
 
 
 
 
 
 
 
 
 
20
21
22
23
24
...
8
9
10
 
 
 
 
 
 
 
 
 
11
12
13
14
15
16
17
18
19
20
21
22
 
23
24
25
0
@@ -8,17 +8,18 @@ module StrokeDB
0
     #
0
     def index_slots(*args)
0
       slots = args.map{|a| a.is_a?(Array) ? a.map{|e|e.to_s} : [a.to_s] }
0
-      view_name = "index_slots_for_#{name}:#{nsurl}"
0
-      doc = document # metadocument
0
-      opts = { :only => name, :slots => slots, :doc_meta => doc }
0
-      doc.index_slots_view = View.define!(view_name, opts) do |view|
0
-        def view.map(uuid, doc)
0
-          meta = self['doc_meta']
0
-          slots.each do |sl|
0
-            k = sl.inject([]) do |a, sn|
0
-              a << sn << doc[sn]
0
+      @meta_initialization_procs << Proc.new do
0
+        view_name = "index_slots_for_#{name}:#{nsurl}"
0
+        opts = { :only => name, :slots => slots, :doc_meta => doc }
0
+        doc.index_slots_view = View.define!(view_name, opts) do |view|
0
+          def view.map(uuid, doc)
0
+            meta = self['doc_meta']
0
+            slots.each do |sl|
0
+              k = sl.inject([]) do |a, sn|
0
+                a << sn << doc[sn]
0
+              end
0
+              [[meta, k], doc]
0
             end
0
-            [[meta, k], doc]
0
           end
0
         end
0
       end

Comments