Method: OccamsRecord::EagerLoaders::Base#scope

Defined in:
lib/occams-record/eager_loaders/base.rb

#scope {|ActiveRecord::Relation| ... } ⇒ Object

An alternative to passing a “scope” lambda to the constructor. Your block is passed the query so you can call select, where, order, etc on it.

If you call scope multiple times, the results will be additive.

Yields:

  • (ActiveRecord::Relation)

    a relation to modify with select, where, order, etc

Returns:

  • self



55
56
57
58
# File 'lib/occams-record/eager_loaders/base.rb', line 55

def scope(&scope)
  @scopes << scope if scope
  self
end