snusnu/substation — pull request #4 by snusnu (2013-06-17 17:26:04+00:00)
Title: Introduce a DSL to construct a chain

Most of the work is already done. Mutant can't find any mutations but shows quite some "noop fails" (most likely due to errors in `to_source`). Most of the devtools rake tasks are not yet happy, as this code is still missing docs and flay/flog/reek adaptions.

- [ ] Make `rake ci` happy
- [ ] Add common processors (at least `call`, maybe also `wrap` and `evaluate`)
- [ ] Add info to the README

The DSL allows you to build environments and construct chains like so:

```ruby
env = Substation::Environment.build do
register :authenticate, Processors::Authenticator
register :authorize, Processors::Authorizer
register :sanitize, Substation::Stack::Sanitizer
register :validate, Substation::Stack::Validator
register :call, Substation::Stack::Pivot
register :wrap, Substation::Stack::Wrapper
end

AUTHENTICATED = env.chain { authenticate }
AUTHORIZED = env.chain(AUTHENTICATED) { authorize }

CREATE_PERSON = env.chain(AUTHORIZED) do
sanitize Sanitizers::NEW_PERSON
validate Validators::NEW_PERSON

call Actions::CreatePerson

wrap Presenters::Person
wrap Views::Person
end
```