Class: Parelation::Applier

Inherits:
Object
  • Object
show all
Defined in:
lib/parelation/applier.rb

Constant Summary collapse

CRITERIA =

Returns the list of active criteria classes that are used to narrow down database results.

Returns:

  • (Array)

    the list of active criteria classes that are used to narrow down database results.

[
  Parelation::Criteria::Select,
  Parelation::Criteria::Limit,
  Parelation::Criteria::Offset,
  Parelation::Criteria::Order,
  Parelation::Criteria::Query,
  Parelation::Criteria::Where,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chain, params) ⇒ Applier

Returns a new instance of Applier.

Parameters:

  • chain (ActionController::Relation)

    the base chain to build on.

  • params (ActionController::Parameters, Hash)

    user input via params.



26
27
28
29
# File 'lib/parelation/applier.rb', line 26

def initialize(chain, params)
  @chain = chain
  @params = params
end

Instance Attribute Details

#chainActiveRecord::Relation (readonly)

Returns:

  • (ActiveRecord::Relation)


17
18
19
# File 'lib/parelation/applier.rb', line 17

def chain
  @chain
end

#paramsActionController::Parameters, Hash (readonly)

Returns:

  • (ActionController::Parameters, Hash)


21
22
23
# File 'lib/parelation/applier.rb', line 21

def params
  @params
end

Instance Method Details

#applyActiveRecord::Relation

Returns the criteria-applied #chain.

Returns:

  • (ActiveRecord::Relation)

    the criteria-applied #chain.



33
34
35
# File 'lib/parelation/applier.rb', line 33

def apply
  @apply ||= apply_to_chain
end