sporkmonger/addressable — pull request #133 by levinalex (2013-07-30 11:27:20+00:00)
Title: Addressable::Template: Substitution with something that is not a Hash

I'm trying to replace my ad-hoc URI-Template parser with Addressable::Template.

However, I don't have the substitutions in Hash form. The current Template implementation assumes that substitutions are Enumerable (it calls `inject` on `mapping`)

Not calling inject makes it possible to pass a lambda (or anything else that responds to `[]` as a substitute:

```
describe "Substituting from an optional block" do
sub = lambda { |x| "foo-#{x}" }
Addressable::Template.new("{bar}/{baz}").expand(sub).to_str.should == "foo-bar/foo-baz"
end
```

Ideally I'd like to change expand to take a block like so:

```
template.expand { |field| "foo-#{field}" }
```

but I'd like to hear what you think about changing the API in that way, especially because that would conflict with #132