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)


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

def paginated?(raw)
  !!(raw.is_a?(Hash) && raw.dig(*total_key))
end

#pagination(data) ⇒ Object



30
31
32
# File 'lib/lhs/concerns/record/pagination.rb', line 30

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

#pagination_classObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/lhs/concerns/record/pagination.rb', line 19

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