Add named document functionality
-
Yurii Rashkovskii
- Assigned user changed from Oleg Andreev to Yurii Rashkovskii
-
Yurii Rashkovskii
Then we can implement meta document creation as
Meta(name, ...) -
Yurii Rashkovskii
and Views as
View(name) do |view| # ... end -
Yurii Rashkovskii
- Milestone set to 0.0.3
- Title changed from Finally consider adding named document functionality to Add named document functionality
-
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 -
Michael Klishin (antares)
Alternative syntax to escape this amount of magic is to use Product.named("OS X 10.5").
-
Yurii Rashkovskii
Michael, I like this idea!
-
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.
-
Yurii Rashkovskii
- State changed from open to resolved
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.