Module: Uberloader::QueryMethods::Delegates

Defined in:
lib/uberloader/query_methods.rb

Instance Method Summary collapse

Instance Method Details

#uberload(association, scope: nil) {|Uberloader::Context| ... } ⇒ ActiveRecord::Relation

Uberload an association.

Category.
  uberload(:widget, scope: Widget.order(:name)) { |u|
    u.uberload(:parts) {
      u.scope Part.active
      u.uberload(:foo)
    }
  }

Parameters:

  • association (Symbol)

    Name of the association

  • scope (ActiveRecord::Relation) (defaults to: nil)

    Optional scope to apply to the association’s query

Yields:

Returns:

  • (ActiveRecord::Relation)


20
21
22
# File 'lib/uberloader/query_methods.rb', line 20

def uberload(association, scope: nil, &block)
  all.uberload(association, scope: scope, &block)
end