DataBroker

Gem Version Semaphore Code Climate Coverage Status Dependency Status License

A simplified implementation of the data mapper pattern

Data Broker

Tired of the Active Record pattern forcing your design decision? Working with a legacy database that doesn't conform to Rails golden path? Then perhaps you need the data mapper pattern.

This library implements an extremely simplified version of the data mapper pattern. It allows you to map POROs (backed by Virtus) to arbitrary tables via ActiveRecord. The DataMapper gem provides this functionality, but not for Ruby 2.x/Rails 4.x. and the alternatives such as datamappify (lots of magic inferances that don't work well with legacy systems) and Ruby Object Mapper (not yet available for production) don't fit our needs at TeamSnap.

Currently DataBroker only allows for a 1-to-1 mapping of objects to tables. In the future we plan to add 1-to-many mappings of objects to tables.

The interface for DataBroker is purposefully lightweight and similar to both datamappify and ruby object mapper so that you can migrate between them with ease.

Installation

Add this line to your application's Gemfile:

gem 'data_broker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install data_broker

Usage

View specs for sample usage.

Roadmap

  • Allow 1-to-many mappings of objects to tables
  • Implement the Unit of Work pattern (i.e. transactions) around 1-to-many mappings

Contributing

  1. Fork it ( http://github.com/teamsnap/data_broker/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. Create new Pull Request