Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Add named document functionality

#44

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.

Reported by Yurii Rashkovskii · May 1st, 2008 @ 04:59 AM

State: resolved
Milestone: 0.0.3
Assigned to: Yurii Rashkovskii Yurii Rashkovskii

Activity

  1. Yurii Rashkovskii
    Yurii Rashkovskii
    • Assigned user changed from Oleg Andreev to Yurii Rashkovskii

    May 1st, 2008 @ 04:52 AM

  2. Yurii Rashkovskii
    Yurii Rashkovskii

    Then we can implement meta document creation as

    Meta(name, ...)
    

    May 1st, 2008 @ 05:04 AM

  3. Yurii Rashkovskii
    Yurii Rashkovskii

    and Views as

     View(name) do |view|
       # ...
     end
    

    May 1st, 2008 @ 05:08 AM

  4. Yurii Rashkovskii
    Yurii Rashkovskii
    • Milestone set to 0.0.3
    • Title changed from Finally consider adding named document functionality to Add named document functionality

    May 1st, 2008 @ 05:30 AM

  5. Yurii Rashkovskii
    Yurii Rashkovskii

    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
    

    May 1st, 2008 @ 07:21 AM

  6. Michael Klishin (antares)
    Michael Klishin (antares)

    Alternative syntax to escape this amount of magic is to use Product.named("OS X 10.5").

    May 2nd, 2008 @ 05:30 AM

  7. Yurii Rashkovskii
    Yurii Rashkovskii

    Michael, I like this idea!

    May 2nd, 2008 @ 05:32 AM

  8. Yurii Rashkovskii
    Yurii Rashkovskii

    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.

    May 3rd, 2008 @ 06:09 AM

  9. Yurii Rashkovskii
  10. Yurii Rashkovskii
    Yurii Rashkovskii
    • State changed from open to resolved

    May 3rd, 2008 @ 09:11 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.