Class: PDC::Response::Paginator

Inherits:
Faraday::Response::Middleware
  • Object
show all
Includes:
Logging
Defined in:
lib/pdc/http/response/pagination.rb

Instance Method Summary collapse

Methods included from Logging

#logger

Instance Method Details

#parse(json) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pdc/http/response/pagination.rb', line 7

def parse(json)
  logger.debug "\n.....paginate json ....................................."

   = json[:metadata]
  logger.debug 
  return json unless paginated?()

  [PDC::Resource::PAGINATION] = {
    resource_count:   .delete(:count),
    # TODO: decide if this is okay to discard the
    # schema://host:port/ of the next and previous
    next_page:        request_uri(.delete(:next)),
    previous_page:    request_uri(.delete(:previous))
  }

  logger.debug '... after parsing pagination data:'
  logger.debug 
  json
end