Sha256: d20c3f37da53414f983378b42670808defcf6353b365d06000f09d84bb688217

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

RescueAny
==========

[![Build Status](https://travis-ci.org/erik-eide/rescue-any.png)](https://travis-ci.org/erik-eide/rescue-any) [![Code Climate](https://codeclimate.com/github/erik-eide/rescue-any.png)](https://codeclimate.com/github/erik-eide/rescue-any)

An experimental library for declarative exception handling in Ruby.

Inspired by Rails's declarative [rescue_from](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/rescuable.rb)
method, this is a bit of an experimental attempt to try something similar that can be used with any Ruby class, as well as to just mess
around with a little meta-programming.

## Usage

```ruby
class RemoteUser
  include RescueAny

  rescue_any RuntimeError, on: [:create, :update, :delete], with: lambda {|ex| puts 'ohoh: ' + ex.message }

  def create
    raise RuntimeError.new("raised by #create")
  end

  def update
    raise RuntimeError.new("raised by #update")
  end

  def delete
    raise RuntimeError.new("raised by #delete")
  end
end
 ```

## Contributing

Feel free to contribute or correct, just:

* Fork this project.
* Write specs, make them pass.
* Updated [CHANGELOG](CHANGELOG.md).
* Make a pull request, bonus for topic branches.

## Copyright and License

Copyright (c) 2013, Erik Eide and [Contributors](CHANGELOG.md).

This project is licensed under the [MIT License](LICENSE).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rescue-any-0.1.1 README.md