Giter Site home page Giter Site logo

orm_adapter's Introduction

ORM Adapter

Provides a single point of entry for popular ruby ORMs. Its target audience is gem authors who want to support more than one ORM.

Example of use

require 'orm_adapter'

User # is it an ActiveRecord, DM Resource, or MongoId Document?

User.to_adapter.find_first :name => 'Fred' # we don't care!

user_model = User.to_adapter
user_model.get!(1)                      # find a record by id
user_model.find_first(:name => 'fred')  # find first fred
user_model.find_all(:name => 'fred')    # find all freds
user_model.find_all(:order => :name)    # find all freds, ordered by name
user_model.create!(:name => 'fred')     # create a fred

@see OrmAdapter::Base for more details of the supported API

Supported ORMs

Currently supported ORMs are ActiveRecord, DataMapper and MongoId.

We welcome you to write new adapters as gems. ORM Adapter will stay focused in having these three major ORMs working.

To write an adapter look at lib/orm_adapter/adapters/active_record.rb for an example of implementation. To see how to test it, look at spec/orm_adapter/example_app_shared.rb, spec/orm_adapter/adapters/active_record_spec.rb. You’ll need to require the target ORM in spec/spec_helper.rb

Goals

ORM Adapter goal is to support a minimum API used by most of the plugins that needs agnosticism beyond Active Model.

ORM Adapter will support only basic methods, as get, find_first, create! and so forth. It is not ORM Adapter’s goal to support different query constructions, handle table joins, etc.

If you need complex queries, we recommend you to subclass ORM Adapters in your plugin and extend it expressing these query conditions as part of your domain logic.

Projects using orm_adapter

Get in touch if you want your project added to this list

History

orm_adapter is an extraction from pickle by Ian White. Pickle’s orm adapter included work by Daniel Neighman, Josh Bassett, Marc Lee, and Sebastian Zuchmanski.

José Valim suggested the extraction, and worked on the first release with Ian.

Development

To run the specs, you can start from the last known good set of gem dependencies in Gemfile.lock.development:

git clone http://github.com/ianwhite/orm_adapter
cd orm_adapter
cp Gemfile.lock.development Gemfile.lock
bundle
bundle exec rake spec

Copyright © 2010-2011 Ian White and José Valim. See LICENSE for details.

orm_adapter's People

Contributors

ianwhite avatar josevalim avatar thhermansen avatar

Watchers

Knut Hellan avatar James Cloos avatar Bilegsaikhan Naidan avatar Luca Venturi avatar Elena Temelkovska avatar

Forkers

mohitmaniar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.