Class: Practical::RelationBuilders::Base

Inherits:
Object
  • Object
show all
Defined in:
app/lib/practical/relation_builders/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload:, relation:) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'app/lib/practical/relation_builders/base.rb', line 6

def initialize(payload:, relation:)
  self.payload = payload
  self.relation = relation
end

Instance Attribute Details

#payloadObject

Returns the value of attribute payload.



4
5
6
# File 'app/lib/practical/relation_builders/base.rb', line 4

def payload
  @payload
end

#relationObject

Returns the value of attribute relation.



4
5
6
# File 'app/lib/practical/relation_builders/base.rb', line 4

def relation
  @relation
end

Instance Method Details

#applied_relationObject



11
12
13
14
15
16
# File 'app/lib/practical/relation_builders/base.rb', line 11

def applied_relation
  scope = apply_filtering(scope: relation)
  scope = apply_ordering(scope: scope)

  return scope
end

#apply_filtering(scope:) ⇒ Object

Raises:

  • (NotImplementedError)


18
19
20
# File 'app/lib/practical/relation_builders/base.rb', line 18

def apply_filtering(scope:)
  raise NotImplementedError
end

#apply_ordering(scope:) ⇒ Object



22
23
24
25
26
# File 'app/lib/practical/relation_builders/base.rb', line 22

def apply_ordering(scope:)
  scope = first_order_sorting(scope: scope)
  scope = second_order_sorting(scope: scope)
  return scope
end

#first_order_sorting(scope:) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'app/lib/practical/relation_builders/base.rb', line 28

def first_order_sorting(scope:)
  raise NotImplementedError
end

#second_order_sorting(scope:) ⇒ Object

Raises:

  • (NotImplementedError)


32
33
34
# File 'app/lib/practical/relation_builders/base.rb', line 32

def second_order_sorting(scope:)
  raise NotImplementedError
end