Class: HALPresenter::Pagination

Inherits:
Object
  • Object
show all
Defined in:
lib/hal_presenter/pagination.rb

Defined Under Namespace

Classes: Uri

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serialized, collection) ⇒ Pagination

Returns a new instance of Pagination.



51
52
53
54
55
# File 'lib/hal_presenter/pagination.rb', line 51

def initialize(serialized, collection)
  @serialized = serialized
  @collection = collection
  @self_uri = Uri.parse serialized.dig(:_links, :self, :href)
end

Class Method Details

.paginate!(serialized, collection) ⇒ Object



47
48
49
# File 'lib/hal_presenter/pagination.rb', line 47

def self.paginate!(serialized, collection)
  new(serialized, collection).call
end

Instance Method Details

#callObject



57
58
59
60
61
62
# File 'lib/hal_presenter/pagination.rb', line 57

def call
  return unless should_paginate?
  add_query_to_self
  add_prev_link
  add_next_link
end