Module: LHS::Record::Pagination::ClassMethods

Defined in:
lib/lhs/concerns/record/pagination.rb

Instance Method Summary collapse

Instance Method Details

#paginated?(raw) ⇒ Boolean

Checks if given raw is paginated or not

Returns:

  • (Boolean)


39
40
41
42
43
44
# File 'lib/lhs/concerns/record/pagination.rb', line 39

def paginated?(raw)
  raw.is_a?(Hash) && (
    raw.dig(*total_key).present? ||
    raw.dig(*limit_key(:body)).present?
  )
end

#pagination(data) ⇒ Object



34
35
36
# File 'lib/lhs/concerns/record/pagination.rb', line 34

def pagination(data)
  pagination_class.new(data)
end

#pagination_classObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/lhs/concerns/record/pagination.rb', line 21

def pagination_class
  case pagination_strategy.to_sym
  when :page
    LHS::Pagination::Page
  when :start
    LHS::Pagination::Start
  when :link
    LHS::Pagination::Link
  else
    LHS::Pagination::Offset
  end
end