Add named document functionality
Reported by Yurii Rashkovskii | May 1st, 2008 @ 07:48 AM | in 0.0.3
The idea is that we seem to have a desperate need in documents identified by their name's UUIDv5.
Here is an example how I might want to do this:
# If there is no such document
Page("/main") # => creates it (no slots defined)
Page("/main", :slot => "value") # => creates it (with slots)
Page(store, "/main") # => creates it in specified store
# If there is such document already:
Page("/main") # => find and return it
Page("/main", :slot => "value") # => finds it, if slots differ, then it update_slot! it
Page(store, "/main") # => finds it in specified store
If called as SomeMeta(), then it should find only documents with given meta. To make it easy, I think we should prepend (or append) name with meta uuid
document.uuid = uuidv5(meta.uuid + name)
This will guarantee no UUIDv5 clashes.
If one wants broader search, he should do it as follows:
Document("page:/main")
Looks pretty nice, I think, and basically not really hard to implement.
P.S. It seems that I definitely need this functionality for Zoid to make things easier.
Comments and changes to this ticket
-
Yurii Rashkovskii May 1st, 2008 @ 07:52 AM
- → Assigned user changed from Oleg Andreev to Yurii Rashkovskii
-
Yurii Rashkovskii May 1st, 2008 @ 08:04 AM
Then we can implement meta document creation as
Meta(name, ...) -
-
Yurii Rashkovskii May 1st, 2008 @ 08:30 AM
- → Milestone changed from to 0.0.3
- → Title changed from Finally consider adding named document functionality to Add named document functionality
-
Yurii Rashkovskii May 1st, 2008 @ 10:21 AM
It is sorta tricky syntax, but following evil hack should help us:
class Object def eigen class << self; self; end end end module Kernel private alias :_method_missing_ :method_missing def method_missing(sym,*args,&block) i = self.is_a?(Module) ? self : self.class if (e = (i.const_get(sym) rescue nil)).is_a?(Meta) i.eigen.send(:define_method,sym) { e.document } i.send(sym,*args,&block) else send(:_method_missing_,sym,*args,&block) end end end -
Michael Klishin (antares) May 2nd, 2008 @ 08:30 AM
Alternative syntax to escape this amount of magic is to use Product.named("OS X 10.5").
-
-
Yurii Rashkovskii May 3rd, 2008 @ 09:09 AM
Added this kind of functionality, but haven't reused it to do Meta.named(...) for metas (that appeared to be a more tricky thing). May be some meta.rb refactoring will help?
Also, Document.named is not implemented yet.
-
-
Yurii Rashkovskii May 3rd, 2008 @ 12:11 PM
- → State changed from open to resolved
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
StrokeDB is an embeddable distributed document database written in Ruby
