Module: ArelTableShortcut

Defined in:
lib/arel_table_shortcut.rb

Overview

In-house replacement for the only feature we used out of the
arel-helpers gem (camertron/arel-helpers): the ArelTable mixin.

Adds a Model[:column_name] shortcut on every ActiveRecord class
(literally Model.arel_table[:column_name]), used in 260+ call sites
across this app for arel predicates:

Order.where(Order[:line_total].gteq(200))
Customer.where(Customer[:state].eq('customer'))
ContactPoint.where(ContactPoint[:detail].matches(term))

This is the entire feature surface from arel-helpers we leaned on
(we never used JoinAssociation or QueryBuilder — BaseQueryBuilder
is an in-house reflect implementation). Inlined here so we can
drop the external dependency.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ void

This method returns an undefined value.

Hook called by Ruby when the module is included into a class. Extends
the class with ClassMethods so Model[:col] works as a class method.

Parameters:

  • base (Class)

    the including class — typically ActiveRecord::Base.



36
37
38
# File 'lib/arel_table_shortcut.rb', line 36

def self.included(base)
  base.extend(ClassMethods)
end