Skip to content

Mixin providing management of error surfaces within the familiar territory of ActiveModel

License

Notifications You must be signed in to change notification settings

pboling/destination_errors

 
 

Repository files navigation

DestinationErrors

Allows you to create a class that has multiple error surfaces registered but stays within the familiar territory of ActiveRecord::Validations.

Project DestinationErrors
gem name destination_errors
license MIT
expert support Get help on Codementor
download rank Total Downloads
version Gem Version
dependencies Dependency Status
code quality Code Climate
inline documenation Inline docs
continuous integration Build Status
test coverage Coverage Status
homepage on Github.com
documentation on Rdoc.info
live chat Join the chat at https://gitter.im/pboling/destination_errors
Spread ♡ⓛⓞⓥⓔ♡ 🌏, 👼, :shipit:, Tweet Peter, 🌹

Installation

Add this line to your application's Gemfile:

gem 'destination_errors'

And then execute:

$ bundle

Or install it yourself as:

$ gem install destination_errors

Usage

Here is a contrived example.

You have three models, and a form that interacts with all of them:

class User
  has_one :profile
  has_one :account
end

class Profile
  belongs_to :user
end

class Account
  belongs_to :user
end

So you create an admin user form presenter class to handle everything, and you want it to be railsy.

class AdminUserFormPresenter

  include DestinationErrors

  attr_accessor :user, :profile, :account
  has_error_surfaces [nil, :user, :profile, :account]

  def initialize(*args)
    @surface_errors_on = nil # nil means errors will be moved onto this instance.
  end

end

For more example usage see the specs.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

Maintenance

To release a new version, update the version number in version.rb, and then run bundle exec rake release to create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.

As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.

For example:

spec.add_dependency 'destination_errors', '~> 0.0'

Contributing

  1. Fork it ( https://github.com/[my-github-username]/destination_errors/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Make sure to add tests!
  6. Create a new Pull Request

Contributors

See the Network View

About

Mixin providing management of error surfaces within the familiar territory of ActiveModel

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.2%
  • Shell 0.8%