mattt/sinatra-param — pull request #21 by soopa (2013-11-18 20:49:44+00:00)
Title: only set parameters present in request or that are given a default value

Currently, writing a contract like `param :name, String` will add the parameter `:name` to the `params` hash with a `nil` value if the parameter was not present in the request. This makes it difficult to avoid unintentionally setting model attributes to `nil` when passing params to the model or setting attributes based on the presence of a parameter.

**Example:**

A request like `patch('/user/1', bio: 'test')` would result in the undesirable effect of `:name` being set to `nil` given common processing logic such as:

```
patch '/users/:id' do |id|
param :name, String
param :bio, String
user = User.get(id)
user.update(params)
…
```
or
```
patch '/users/:id' do |id|
param :name, String
param :bio, String
user = User.get(id)
user.name == params[:name] if params.member?(:name)
user.bio == params[:bio] if params.member?(:bio)
…
```

This patch checks for presence of `param` that is not required and does not have a default value in request parameters hash before setting the parameter. Spec included.