Handshake 0.2.1 Released
2007-05-01 22:45:00 -0400I’ve pushed out a new version of Handshake. The big-ticket item in 0.2 is that method argument contracts now support contracts on blocks. When a block is passed to a method that’s protected by a block contract, the block will be modified to check the arguments and return values for that block in much the same way that a normal contract is checked. Note that this will probably not work in Ruby 1.9, or at least will have to be modified for recursive contract checking.
Here’s the syntax:
class StringArray < Array
contract :each, Block(String => anything) => self
end
Block checking in 0.2.0 involved reopening the Proc class; release 0.2.1 fixes that.
The new release also contains a new method, checked_self
. Because of the way Handshake is implemented (with a proxy object), calls to private methods aren’t checked (because they’re called on the real object instead of the proxy object). checked_self
returns the proxy object instance and calls made to that object will be contract checked.
I’ve also improved the documentation. You can find the rdoc at http://handshake.rubyforge.org, and the project page at http://rubyforge.org/projects/handshake/.