Module: ParamsReady::Pagination::Direction::Before

Extended by:
ParamsReady::Pagination::Direction
Defined in:
lib/params_ready/pagination/direction.rb

Class Method Summary collapse

Methods included from ParamsReady::Pagination::Direction

build_cursor, check_primary_keys_presence, cursor_predicate, cursor_predicates, instance, non_nullable_predicate, nullable_predicate, pk_predicate

Class Method Details

.invert_ordering?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/params_ready/pagination/direction.rb', line 90

def self.invert_ordering?
  true
end

.keysets(_, keysets, &block) ⇒ Object



112
113
114
# File 'lib/params_ready/pagination/direction.rb', line 112

def self.keysets(_, keysets, &block)
  BeforeKeysets.new(keysets, &block)
end

.nulls_strategy(strategy) ⇒ Object



103
104
105
106
107
108
109
110
# File 'lib/params_ready/pagination/direction.rb', line 103

def self.nulls_strategy(strategy)
  case strategy
  when :first then Nulls::Last
  when :last then Nulls::First
  else
    raise ParamsReadyError, "Unexpected nulls strategy: '#{strategy}'"
  end
end

.tendency(ordering) ⇒ Object



94
95
96
97
98
99
100
101
# File 'lib/params_ready/pagination/direction.rb', line 94

def self.tendency(ordering)
  case ordering
  when :desc then Tendency::Growing
  when :asc then Tendency::Falling
  else
    raise ParamsReadyError, "Unexpected ordering: '#{ordering}'"
  end
end