Class: ATDIS::Models::Page
Instance Attribute Summary
Attributes inherited from ATDIS::Model
#attributes, #attributes_before_type_cast, #json_left_overs, #json_load_error, #timezone, #url
Instance Method Summary
collapse
attribute_keys, attribute_names, cast, cast_datetime, cast_geojson, cast_integer, cast_string, cast_uri, hash_symbols_to_string, #initialize, interpret, #json_errors, #json_errors_in_children, #json_errors_local, #json_left_overs_is_empty, #json_loaded_correctly!, partition_by_used, read_json, read_url, read_url_raw, #used_attribute?
Constructor Details
This class inherits a constructor from ATDIS::Model
Instance Method Details
If some of the pagination fields are present all of the required ones should be present
27
28
29
30
31
|
# File 'lib/atdis/models/page.rb', line 27
def
return unless && count.nil?
errors.add(:count, ErrorMessage["should be present if pagination is being used", "6.4"])
end
|
#count_is_consistent ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/atdis/models/page.rb', line 33
def count_is_consistent
return if count.nil?
if response.respond_to?(:count)
if count != response.count
errors.add(
:count,
ErrorMessage["is not the same as the number of applications returned", "6.4"]
)
end
end
return unless .respond_to?(:per_page) && .per_page
return unless count > .per_page
errors.add(
:count,
ErrorMessage["should not be larger than the number of results per page", "6.4"]
)
end
|
#next_page ⇒ Object
70
71
72
|
# File 'lib/atdis/models/page.rb', line 70
def next_page
Page.read_url(next_url, timezone) if next_url
end
|
#next_url ⇒ Object
60
61
62
63
64
|
# File 'lib/atdis/models/page.rb', line 60
def next_url
raise "Can't use next_url when loaded with read_json" if url.nil?
ATDIS::SeparatedURL.merge(url, page: .next) if &.next
end
|
#previous_page ⇒ Object
66
67
68
|
# File 'lib/atdis/models/page.rb', line 66
def previous_page
Page.read_url(previous_url, timezone) if previous_url
end
|
#previous_url ⇒ Object
54
55
56
57
58
|
# File 'lib/atdis/models/page.rb', line 54
def previous_url
raise "Can't use previous_url when loaded with read_json" if url.nil?
ATDIS::SeparatedURL.merge(url, page: .previous) if &.previous
end
|