roundlake/wash_out — pull request #31 by rngtng (2012-04-13 14:46:27+00:00)
Title: Split params parsing into two before_filters

**Disclamer:** I cloudn't figure out the reason why [Dispatcher parses request params](https://github.com/rngtng/wash_out/blob/master/lib/wash_out/dispatcher.rb#L28) again. My ony explanation was to be on the *save* site in case the framework doesn't provide any mechanism. But as for my Rails version 3.2.3 params parsing is already included. This PR proposes a simple solution for custom parser:

This PR splits request params parsing into two before_filter:

* _parse_soap_parameters
* _map_soap_parameters

This has the advantage to be able to overwrite the filters with own parsers (or on rails just disable the included one). E.g my rails controller now looks like this:

```ruby
class SoapController < ApplicationController
include WashOut::SOAP

def _parse_soap_parameters
@_params = params
end

....
```

This is not only faster, but allows me to follow my usual controller test style:

```ruby
describe "myaction" do
render_views

before do
request.env['wash_out.soap_action'] = "myaction"
end

let(:valid_params) do
{
"Envelope" => {
"xmlns:soap" => "http://schemas.xmlsoap.org/soap/envelope/",
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
"Body" => {
"myaction" => {
"request" => "hello"
}
}
}
},
"action" => "_action"
}
end

it "responds ok" do
post :myaction, valid_params

response.body.should include("world")
end
end
```

Maybe, as we assume a quite tight coupling with rails anyway, we could get rid of the parser too?