Class: ATDIS::Models::Page
Instance Attribute Summary
Attributes inherited from ATDIS::Model
#attributes, #attributes_before_type_cast, #json_left_overs, #json_load_error, #url
Instance Method Summary
collapse
attribute_keys, attribute_names, cast, #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, #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
24
25
26
27
28
|
# File 'lib/atdis/models/page.rb', line 24
def
if && count.nil?
errors.add(:count, ErrorMessage["should be present if pagination is being used", "6.4"])
end
end
|
#count_is_consistent ⇒ Object
30
31
32
33
34
35
|
# File 'lib/atdis/models/page.rb', line 30
def count_is_consistent
if count
errors.add(:count, ErrorMessage["is not the same as the number of applications returned", "6.4"]) if count != response.count
errors.add(:count, ErrorMessage["should not be larger than the number of results per page", "6.4"]) if count > .per_page
end
end
|
#next_page ⇒ Object
51
52
53
|
# File 'lib/atdis/models/page.rb', line 51
def next_page
Page.read_url(next_url) if next_url
end
|
#next_url ⇒ Object
42
43
44
45
|
# File 'lib/atdis/models/page.rb', line 42
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
47
48
49
|
# File 'lib/atdis/models/page.rb', line 47
def previous_page
Page.read_url(previous_url) if previous_url
end
|
#previous_url ⇒ Object
37
38
39
40
|
# File 'lib/atdis/models/page.rb', line 37
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
|