attributes ala java annotations or .Net attributes?

K

Kyle Schmitt

Does ruby have attributes ala java annotations or .Net attributes?
I've never seen them in use, hence my wondering.
Right now I've got a pretty big test-suite written in ruby & watir,
and I've got alot of old code in it. It would be nice if I just was
able to put in something like an [obsolete]/<obsolete> tag, and have
it just ignored, or have a warning popup automatically to say "Your'e
using an obsolete method, get with it!", or to bip me on the head...

Is there anything like this?

Thanks,
Kyle
 
T

Trans

Does ruby have attributes ala java annotations or .Net attributes?
I've never seen them in use, hence my wondering.
Right now I've got a pretty big test-suite written in ruby & watir,
and I've got alot of old code in it. It would be nice if I just was
able to put in something like an [obsolete]/<obsolete> tag, and have
it just ignored, or have a warning popup automatically to say "Your'e
using an obsolete method, get with it!", or to bip me on the head...

Is there anything like this?

Facets has an annotations system, but of course it's not an built-in
part of ruby. So it simply supplies a general way to tag you code.
It's up to you to actually make it do something. Basic example:

require 'facets/annotations'

class Y

ann :x, :eek:bsolete => true

def x
...
end
end

Y.ann:)x, :eek:bsolete) #=> true

So to use that to ignore methods, I suppose you'd want to use
ObjectSpect.each_object(Class) to loop through the classes and
undefine obsolete methods. For warnings, you could wrap them instead.

T.
 
B

Ben Bleything

Does ruby have attributes ala java annotations or .Net attributes?
I've never seen them in use, hence my wondering.
Right now I've got a pretty big test-suite written in ruby & watir,
and I've got alot of old code in it. It would be nice if I just was
able to put in something like an [obsolete]/<obsolete> tag, and have
it just ignored, or have a warning popup automatically to say "Your'e
using an obsolete method, get with it!", or to bip me on the head...

It's not exactly what you're looking for, but there's a library called
'deprecated' that can be used to achieve that sort of result:

http://rubyforge.org/projects/deprecated/

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top