"Ilias Lazaridis" <ilias / lazaridis.com> schrieb im Newsbeitrag
news:d2r96v$c9c$1 / usenet.otenet.gr...
> Csaba Henk wrote:
> > On 2005-04-04, Robert Klemme <bob.news / gmx.net> wrote:
> >
> >>"Saynatkari" <ruby-ml / magical-cat.org> schrieb im Newsbeitrag
> >>
> >>>You are not accessing the method, you are _calling_ the method.
> >>>As mentioned earlier, talker.method(:sayYourName).meta would
> >>>work.
> >>
> >>No, it doesn't.  Method instances are not suited to carrying meta
data:
> >
> > [snip]
> >
> >>The reason is that Method instances are created on each request:
> >
> > Hmm, that's interesting. Good to know of it. So then methods are not
> > objects per se, they just can be objectified.
> >
> > Then really talker.meta[:sayYourName][:author] is the way to go. Of
> > course, if the metadata is not intended/needed to be
instance-specific,
> > then it's better to be appended to the class.
> >
> > Csaba
>
> Thank's to all replies.
>
> I've understood now the problem.
>
> -
>
> The Ruby Object Model does not contain reflective MetaClasses, which
> would enable to apply metadata even to methods.

I'm not sure what exactly you mean by this.  You can indeed access classes
in Ruby.  So I'd say there *are* MetaClasses.  It's just that there is no
persistent representation of methods which you could augment with
additional data.

> I would like to know how a class which i've defined is represented in
> memory, and how I can access it.

You just access them like any object, only that class instances are
assigned to constants:

>> class Foo;end
=> nil
>> Foo.instance_variables
=> []
>> class Foo
>> class <<self
>> attr_accessor :bar
>> end
>> end
=> nil
>> Foo.bar = "test"
=> "test"
>> Foo.bar
=> "test"
>> Foo.instance_variables
=> ["@bar"]
>> o=Foo
=> Foo
>> o.new
=> #<Foo:0x10185728>

> A Visual representation of the Relevant Ruby Object Model (e.g. with
> UML) would be very helpfull to understand this immediately.

I don't know whether such thing exists, but the concept is usually easy
grasped IMHO.  Try to play a bit with classes in IRB - that helped me a
lot.  Note especially methods #class, #ancestors and #superclass.

Kind regards

    robert