Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed Aug 3, 2017
1 parent 4163359 commit 3da57e2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ hash.forbid!(two: 'two') # => {}
hash # => {}
```

### Type sensitive for `Hash`
#### Type sensitive for `Hash`

```ruby
hash = { 'one' => 'one', 'two' => 'two' }
Expand All @@ -53,6 +53,8 @@ hash.forbid(one: 'one') # => { "one" => "one", "two" => "two" }
hash.forbid('one' => 'one') # => { "two" => "two" }
```

## With Rails and strong parameters

When added to the `Gemfile` in a Rails project, `ActionController::Parameters` will also receive these methods so you can use them with your `strong_parameters`:

```ruby
Expand All @@ -61,7 +63,7 @@ def user_params
end
```

### Type insensitive for `HashWithIndifferentAccess`
#### Type insensitive for `HashWithIndifferentAccess`
```ruby
params = ActionController::Parameters.new('one' => 'one', 'two' => 'two').permit(:one, :two)

Expand All @@ -70,10 +72,12 @@ params.forbid(one: 'one').to_h # => { "two" => "two" }
params.forbid('one' => 'one').to_h # => { "two" => "two" }
```

If your custom `Hash`-like class implements the `#[]` finder and `#delete`, you can `include Forbidium` to mix in the methods.
If your custom `Hash`-like class implements `#delete` and the `#[]` finder, you can `include Forbidium` to mix in the methods.

## Platform support

This gem should work with Ruby >= 2.0.0, however at the moment it is only tested for Ruby >= 2.2.2

Tested against:
* MRI 2.2.2
* MRI 2.3.0
Expand Down

0 comments on commit 3da57e2

Please sign in to comment.