RetroMocha/obvious — pull request #15 by bundacia (2013-01-14 20:06:08+00:00)
Title: DSL for contracts

The method for defining contracts seemed a little more complex than it needed to be:

```ruby
contracts :save

def save_contract input
input_shape = User.shape
output_shape = User.shape
call_method :save_alias, input, input_shape, output_shape
end
```

This requires me to know how the Contract class is renaming methods save_contract and save_alias and will make it hard or impossible for those behind-the-scenes details to change in the future without breaking compatibility. I also have to write the `save_contract` method _and_ list it as a contract at the top of the file. What I've attempted to do is introduce a bit of a DSL for expressing the same logic in a simpler, declarative style. So the above becomes this:

```ruby
contract_for :save, {
:input => Status.shape,
:output => Status.shape,
}
```

I'm open to ideas if you think there's a better way to do this. Let me know what you think.

Trevor

PS. I'll be submitting a pull request to update the obvious_status example to use this new format.