Sha256: 1fe025c53f1bb2f98024afdcd3c5ec94453c41b660184beb7b1f7f46c0bc8cd3

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# DealWithIt

![DealWithIt](./dealwithit.png)

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'deal_with_it'
```

And then execute:

```
$ bundle
```

## Usage

Include the handler base on your ApplicationController or in any class you wish to handle.

```ruby
class ApplicationController < ActionController::Base
  include DealWithIt
end
```

Create your custom handler anywhere in the app.

```ruby
# app/handlers/record_not_found_handler.rb
class RecordNotFoundHandler < DealWithIt::Handler
  deal ActiveRecord::RecordNotFound, with: ->(error) do
    render json: { 'Oopsie, we didn\'t found that stuff' }, status: :not_found
  end
end
```

Note that `render` is a method that comes from the ActionController itself, it could be any method from the class that included the DealWithIt module.

## Contributing

Bug reports and pull requests are welcome on GitHub at <https://github.com/leonardofalk/deal_with_it>.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deal_with_it-0.1.0 README.md