Module: ArelTableShortcut::ClassMethods

Defined in:
lib/arel_table_shortcut.rb

Overview

Class-level methods extended onto every including ActiveRecord class.

Instance Method Summary collapse

Instance Method Details

#[](column_name) ⇒ Arel::Attributes::Attribute

Model[:column] shortcut for Model.arel_table[:column].

Written as an explicit method rather than delegate :[], to: :arel_table
because YARD's DSL handler crashes on delegate with an operator name.

column_name (Symbol or String) is the column to expose as an Arel
attribute. Aliased columns work because arel_table resolves them.

Returns:

  • (Arel::Attributes::Attribute)

    the attribute node, ready to
    chain Arel predicates (.eq, .gt, .in, .matches, .lower,
    .or, etc.) against.



31
# File 'lib/arel_table_shortcut.rb', line 31

def [](column_name) = arel_table[column_name] # rubocop:disable Rails/Delegate -- YARD's DSL handler crashes on this delegate form