Module: Mongoid::Criteria::Queryable::Forwardable

Included in:
Findable
Defined in:
build/mongoid-7.0/lib/mongoid/criteria/queryable/forwardable.rb

Overview

Allows for easy delegation of queryable queryable instance methods to a specific method.

Instance Method Summary collapse

Instance Method Details

#select_with(receiver) ⇒ Array<Symbol>

Tells queryable with method on the class to delegate to when calling an original selectable or optional method on the class.

Examples:

Tell queryable where to select from.

class Band
  extend Queryable::Forwardable
  select_with :criteria

  def self.criteria
    Query.new
  end
end

Parameters:

  • receiver (Symbol)

    The name of the receiver method.

Returns:

  • (Array<Symbol>)

    The names of the forwarded methods.

Since:

  • 1.0.0



28
29
30
31
32
# File 'build/mongoid-7.0/lib/mongoid/criteria/queryable/forwardable.rb', line 28

def select_with(receiver)
  (Selectable.forwardables + Optional.forwardables).each do |name|
    __forward__(name, receiver)
  end
end