Module: Rql::Scope::BlockMethods

Included in:
BlockMethodGroup, RqlScope
Defined in:
lib/rql/scope/block_methods.rb

Instance Method Summary collapse

Instance Method Details

#includes { ... } ⇒ Rql::Scope::RqlScope

Includes the specified associated models

Yields:

  • RQL block defining the associations to include

Returns:



40
41
42
# File 'lib/rql/scope/block_methods.rb', line 40

def includes(&block)
  scope.includes(*build_join_path(&block))
end

#joins { ... } ⇒ Rql::Scope::RqlScope

Joins to the specified associated models

Yields:

  • RQL block defining the associations to join to

Returns:



32
33
34
# File 'lib/rql/scope/block_methods.rb', line 32

def joins(&block)
  scope.joins(*build_join_path(&block))
end

#order { ... } ⇒ Rql::Scope::RqlScope

Orders by specified attributes

Yields:

  • RQL block defining the attributes order by

Returns:



24
25
26
# File 'lib/rql/scope/block_methods.rb', line 24

def order(&block)
  scope.order(*build_attributes(&block))
end

#select { ... } ⇒ Rql::Scope::RqlScope

Specifies attributes to be selected from the database

Yields:

  • RQL block defining the attributes to be selected

Returns:



16
17
18
# File 'lib/rql/scope/block_methods.rb', line 16

def select(&block)
  scope.select(*build_attributes(true, &block))
end

#where { ... } ⇒ Rql::Scope::RqlScope

Filters scope based on specified conditions

Yields:

  • RQL block defining the conditions to filter on

Returns:



8
9
10
# File 'lib/rql/scope/block_methods.rb', line 8

def where(&block)
  scope.where(scope.eval_rql(&block).arel)
end