Skip to content

rootstrap/arqo

Repository files navigation

ARQO ARQO

ARQO (Active Record Query Objects) is a minimal gem that let you use Query Objects in an easy and Rails friendly way. It leverages ActiveRecord features and tries to make query objects as intuitive as possible for developers. In combination with the documentation we hope ARQO helps people keep their projects well structured and healthy.

CI Maintainability Test Coverage

Table of Contents

Motivation

ActiveRecord provides us with an amazing abstraction of the database structure, allowing us to write queries in a simple way. Unfortunately, models can grow large for several reasons, one of them being adding a lot of scopes or placing querying logic in methods.

For this reason is that we created ARQO, so that the query logic is placed into specific objects responsible for building queries while not losing any of the benefits that Rails gives us.

Why ARQO?

  • It is really simple, but still enough to have the best of Rails & query objects.

  • It will dynamically add scopes to your ActiveRecord::Relation instances, clearly making a separation of concerns by not making them accessible through the model.

  • It supports chaining methods defined in the query object just like when using Rails scopes.

  • It centralizes the querying logic of your models in a single source of truth.

Installation

Add this line to your application's Gemfile:

gem 'arqo'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install arqo

Usage

In the following sections we explain some basic usage and the API provided by the gem.

Setting up a query object