Module: DHS::Record::Pagination::ClassMethods
- Defined in:
- lib/dhs/concerns/record/pagination.rb
Instance Method Summary collapse
-
#paginated?(raw) ⇒ Boolean
Checks if given raw is paginated or not.
- #pagination(data) ⇒ Object
- #pagination_class ⇒ Object
Instance Method Details
#paginated?(raw) ⇒ Boolean
Checks if given raw is paginated or not
41 42 43 44 45 46 |
# File 'lib/dhs/concerns/record/pagination.rb', line 41 def paginated?(raw) raw.is_a?(Hash) && ( raw.dig(*total_key).present? || raw.dig(*limit_key(:body)).present? ) end |
#pagination(data) ⇒ Object
36 37 38 |
# File 'lib/dhs/concerns/record/pagination.rb', line 36 def pagination(data) pagination_class.new(data) end |
#pagination_class ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dhs/concerns/record/pagination.rb', line 21 def pagination_class case pagination_strategy.to_sym when :page DHS::Pagination::Page when :total_pages DHS::Pagination::TotalPages when :start DHS::Pagination::Start when :link DHS::Pagination::Link else DHS::Pagination::Offset end end |