Project

errorable

0.0
No commit activity in last 3 years
No release in over 3 years
Adds Active Record error tracking behavior to standard ruby classes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 0
 Project Readme

Errorable

Pronounced like 'adorable' :D

This gem adds ActiveRecord-like error tracking to standard ruby classes. It's super lightweight and requires zero dependencies.

Installation

If you're using Rails/Bundle, include Errorable in your Gemfile:

gem 'errorable'

Otherwise, you can install it from rubygems.org:

gem install errorable

Usage

Include the Errorable module in your class:

class MyClass
  include Errorable
end

Errorable gives you access to these methods:

  1. get_errors
  2. add_error
  3. flush_errors
  4. errors?

You can now add/retrieve errors:

@my_class = MyClass.new
@my_class.add_error("Hello, there was a problem!")
@my_class.add_error("Oh no, another problem!")
@my_class.get_errors
=> [ "Hello, there was a problem!", "Oh no, another problem!" ]

flush_errors returns the errors and empties out the cache of errors.

errors? returns a boolean to tell you if there are errors or not.