Class: CursorPager::SliceRelation

Inherits:
Object
  • Object
show all
Defined in:
lib/cursor_pager/slice_relation.rb

Overview

Applies after and before cursors to a relation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_relation, order_values, after_values, before_values) ⇒ SliceRelation

Returns a new instance of SliceRelation.



8
9
10
11
12
13
# File 'lib/cursor_pager/slice_relation.rb', line 8

def initialize(base_relation, order_values, after_values, before_values)
  @base_relation = base_relation
  @order_values = order_values
  @after_values = after_values
  @before_values = before_values
end

Instance Attribute Details

#after_valuesObject (readonly)

Returns the value of attribute after_values.



6
7
8
# File 'lib/cursor_pager/slice_relation.rb', line 6

def after_values
  @after_values
end

#base_relationObject (readonly)

Returns the value of attribute base_relation.



6
7
8
# File 'lib/cursor_pager/slice_relation.rb', line 6

def base_relation
  @base_relation
end

#before_valuesObject (readonly)

Returns the value of attribute before_values.



6
7
8
# File 'lib/cursor_pager/slice_relation.rb', line 6

def before_values
  @before_values
end

#order_valuesObject (readonly)

Returns the value of attribute order_values.



6
7
8
# File 'lib/cursor_pager/slice_relation.rb', line 6

def order_values
  @order_values
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
# File 'lib/cursor_pager/slice_relation.rb', line 15

def call
  relation = base_relation

  relation = apply_after(relation)
  relation = apply_before(relation)

  relation
end