lib/ably/models/paginated_result.rb in ably-0.8.2 vs lib/ably/models/paginated_result.rb in ably-0.8.3
- old
+ new
@@ -1,8 +1,8 @@
module Ably::Models
# Wraps any Ably HTTP response that supports paging and provides methods to iterate through
- # the pages using {#first}, {#next}, {#first?}, {#has_next?} and {#last?}
+ # the pages using {#first}, {#next}, {#has_next?} and {#last?}
#
# All items in the HTTP response are available in the Array returned from {#items}
#
# Paging information is provided by Ably in the LINK HTTP headers
#
@@ -66,18 +66,10 @@
def last?
!supports_pagination? ||
pagination_header('next').nil?
end
- # True if this is the first page in the paged resource set
- #
- # @return [Boolean]
- def first?
- !supports_pagination? ||
- pagination_header('first') == pagination_header('current')
- end
-
# True if there is a subsequent page in this paginated set available with {#next}
#
# @return [Boolean]
def has_next?
supports_pagination? && !last?
@@ -92,12 +84,11 @@
def inspect
<<-EOF.gsub(/^ /, '')
#<#{self.class.name}:#{self.object_id}
@base_url="#{base_url}",
- @first?=#{!!first?},
- @last?=#{!!first?},
+ @last?=#{!!last?},
@has_next?=#{!!has_next?},
@items=
#{items.map { |item| item.inspect }.join(",\n ") }
>
EOF
@@ -130,10 +121,10 @@
def pagination_header(id)
pagination_headers[id]
end
def pagination_url(id)
- raise Ably::Exceptions::InvalidPageError, "Paging header link #{id} does not exist" unless pagination_header(id)
+ raise Ably::Exceptions::PageMissing, "Paging header link #{id} does not exist" unless pagination_header(id)
if pagination_header(id).match(%r{^\./})
"#{base_url}#{pagination_header(id)[2..-1]}"
else
pagination_header[id]