George Moschovitis wrote:

> sure, first of all, enable typechecking:
> 
> Property.type_checking = true
> 
> then define your class:
> 
> class Article
>     prop_accessor :name, String
> end
> 
> the try to violate tha prop_accessor type:
> 
> a = Article.new
> a.name = 123    # => You get an exception!
> 
> useful to catch some bugs.
> 
> btw, this is NOT an restricted to Og application, this is not
> an Og feature.

Interesting stuff.

I'm currently working on the ruby-contract library (see 
ruby-contract.rubyforge.org) that would allow you to do something 
similar like this:

class Article
   attr_accessor :name
   signature :name=, String
   signature :name, :return => String # optional
end

I've also implemented type adaption so the above would also accept 
anything that implements the .to_str method correctly. (Pathname and so on)

Feedback or questions are very welcome.