Class: Practical::RelationBuilders::Base
- Inherits:
-
Object
- Object
- Practical::RelationBuilders::Base
- Defined in:
- app/lib/practical/relation_builders/base.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#relation ⇒ Object
Returns the value of attribute relation.
Instance Method Summary collapse
- #applied_relation ⇒ Object
- #apply_filtering(scope:) ⇒ Object
- #apply_ordering(scope:) ⇒ Object
- #first_order_sorting(scope:) ⇒ Object
-
#initialize(payload:, relation:) ⇒ Base
constructor
A new instance of Base.
- #second_order_sorting(scope:) ⇒ Object
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
#payload ⇒ Object
Returns the value of attribute payload.
4 5 6 |
# File 'app/lib/practical/relation_builders/base.rb', line 4 def payload @payload end |
#relation ⇒ Object
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_relation ⇒ Object
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
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
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
32 33 34 |
# File 'app/lib/practical/relation_builders/base.rb', line 32 def second_order_sorting(scope:) raise NotImplementedError end |