Module: Babik::QuerySet::Projectable

Included in:
AbstractBase
Defined in:
lib/babik/queryset/mixins/projectable.rb

Overview

Project functionality of QuerySet

Instance Method Summary collapse

Instance Method Details

#project!(*attributes) ⇒ QuerySet

Prepares a projection of only some attributes

Parameters:

  • *attributes (Array)

    Attributes that will be projected. Each one of these can be a local field, or a foreign entity field. Babik will take care of joins.

Returns:

  • (QuerySet)

    Reference to this QuerySet.



13
14
15
16
# File 'lib/babik/queryset/mixins/projectable.rb', line 13

def project!(*attributes)
  @_projection = Babik::QuerySet::Projection.new(@model, attributes)
  self
end

#projection?Boolean

Inform if there is the QuerySet is configured with a projection

Returns:

  • (Boolean)

    True if there is a projection configured, false otherwise.



27
28
29
30
# File 'lib/babik/queryset/mixins/projectable.rb', line 27

def projection?
  return true if @_projection
  false
end

#unproject!QuerySet

Removes the projection.

Returns:

  • (QuerySet)

    Reference to this QuerySet.



20
21
22
23
# File 'lib/babik/queryset/mixins/projectable.rb', line 20

def unproject!
  @_projection = nil
  self
end