[Nitro] TRANS: Facets annotation problems

Michael Fellinger manveru at weez-int.com
Wed Sep 20 03:05:19 EDT 2006


Heya,

Well, guess i should apologize as well, since annotations drove my weak brain 
mad.
but it was just impossible for us to figure out how they actually are intended 
to work and how they really work.
could you please explain us some more things given some examples?

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< lots of code >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

require 'rubygems'
require 'facets/more/annotation'

class A
  # those seem to be annotations for the class itself?
  ann.self.foo = 1
  ann self, :foo => 2

  # annotations for instances?
  ann[:foo] = 3
  ann.foo = 4
end

a = A.new
# #<A:0xb7743b48>
a.ann.self.foo
# 2
a.ann.self[:foo]
# 2
a.ann.self['foo']
# 2

# ok, this seems to work, and .foo [:foo] and ['foo'] are indentical

a.ann[:foo]
# null

# uh...

A.ann[:foo]
# null
A.ann.self.foo
# 2
A.ann.self[:foo]
# 2
A.ann.foo
# null

# same thing again...
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<</ lots of code >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

ok, i've got no idea what's going on there :)
but it seems rather mysterious to say .self all the time and get null 
otherwise.
also, regarding ? and ! - i didn't check if they work properly, i just got 
some errors regarding these lines:

owner_class.ann :self, :join_tables => [] unless owner_class.ann.join_tables?
owner_class.ann.join_tables! << join_table_info

and... well, i just thought there was some mysterious and deep magic going 
on... calling methods on a method with ! seems to me very un-ruby-like :)
i somehow got that ? returns a boolean, but in some cases i got a usual object 
back, not true|false, so i was stupified by that as well.

could you explain in a couple of sentences what annotations are made for, how 
they are integrated in nitro (and especially, og) and how we should make use 
of them?

thanks a lot in advance :)
MfG
manveru

-- 
Weez International Limited

East Roppongi Bldg 5F, 509
3-16-35 Roppongi, Minato-ku Tokyo #106-0032
Tel: 81-(0)3-3505-3881 Fax: 81-(0)3-3505-3883
E-mail: manveru at weez-int.com
Website: http://weez-int.com


More information about the Nitro-general mailing list