esp_sdk 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +11 -1
- data/README.md +287 -28
- data/bin/esp +15 -0
- data/esp_sdk.gemspec +2 -0
- data/lib/esp/aws_clients.rb +60 -0
- data/lib/esp/commands/add_external_account.rb +57 -0
- data/lib/esp/commands/commands_tasks.rb +106 -0
- data/lib/esp/commands/console.rb +68 -0
- data/lib/esp/extensions/active_resource/formats/json_api_format.rb +12 -4
- data/lib/esp/extensions/active_resource/paginated_collection.rb +5 -5
- data/lib/esp/extensions/active_resource/validations.rb +1 -1
- data/lib/esp/external_account_creator.rb +77 -0
- data/lib/esp/resources/alert.rb +30 -34
- data/lib/esp/resources/cloud_trail_event.rb +5 -0
- data/lib/esp/resources/contact_request.rb +6 -5
- data/lib/esp/resources/custom_signature.rb +32 -56
- data/lib/esp/resources/dashboard.rb +8 -1
- data/lib/esp/resources/external_account.rb +27 -19
- data/lib/esp/resources/organization.rb +27 -3
- data/lib/esp/resources/region.rb +15 -3
- data/lib/esp/resources/report.rb +28 -24
- data/lib/esp/resources/resource.rb +26 -10
- data/lib/esp/resources/service.rb +5 -0
- data/lib/esp/resources/signature.rb +28 -12
- data/lib/esp/resources/stat.rb +21 -2
- data/lib/esp/resources/stat_custom_signature.rb +30 -4
- data/lib/esp/resources/stat_region.rb +29 -3
- data/lib/esp/resources/stat_service.rb +29 -3
- data/lib/esp/resources/stat_signature.rb +29 -3
- data/lib/esp/resources/sub_organization.rb +27 -3
- data/lib/esp/resources/suppression/region.rb +14 -32
- data/lib/esp/resources/suppression/signature.rb +14 -40
- data/lib/esp/resources/suppression/unique_identifier.rb +8 -6
- data/lib/esp/resources/suppression.rb +43 -5
- data/lib/esp/resources/tag.rb +5 -0
- data/lib/esp/resources/team.rb +33 -9
- data/lib/esp/resources/user.rb +29 -3
- data/lib/esp/version.rb +1 -1
- data/lib/esp.rb +25 -5
- data/test/esp/aws_clients_test.rb +101 -0
- data/test/esp/extensions/active_resource/formats/json_api_format_test.rb +26 -12
- data/test/esp/extensions/active_resource/paginated_collection_test.rb +93 -72
- data/test/esp/extensions/active_resource/validations_test.rb +2 -12
- data/test/esp/external_account_creator_test.rb +153 -0
- data/test/esp/resources/alert_test.rb +71 -33
- data/test/esp/resources/cloud_trail_event_test.rb +9 -1
- data/test/esp/resources/contact_request_test.rb +8 -0
- data/test/esp/resources/custom_signature_test.rb +8 -0
- data/test/esp/resources/dashboard_test.rb +8 -0
- data/test/esp/resources/external_account_test.rb +8 -0
- data/test/esp/resources/metadata_test.rb +1 -1
- data/test/esp/resources/organization_test.rb +8 -0
- data/test/esp/resources/region_test.rb +12 -4
- data/test/esp/resources/report_test.rb +13 -4
- data/test/esp/resources/resource_test.rb +208 -64
- data/test/esp/resources/service_test.rb +8 -0
- data/test/esp/resources/signature_test.rb +15 -9
- data/test/esp/resources/stat_custom_signature_test.rb +9 -1
- data/test/esp/resources/stat_region_test.rb +23 -1
- data/test/esp/resources/stat_service_test.rb +23 -1
- data/test/esp/resources/stat_signature_test.rb +23 -1
- data/test/esp/resources/stat_test.rb +52 -8
- data/test/esp/resources/sub_organization_test.rb +8 -0
- data/test/esp/resources/suppression/region_test.rb +10 -2
- data/test/esp/resources/suppression/signature_test.rb +10 -2
- data/test/esp/resources/suppression/unique_identifier_test.rb +10 -2
- data/test/esp/resources/suppression_test.rb +74 -14
- data/test/esp/resources/tag_test.rb +9 -1
- data/test/esp/resources/team_test.rb +8 -0
- data/test/esp/resources/user_test.rb +49 -19
- data/test/esp_test.rb +19 -1
- data/test/factories/alerts.rb +70 -0
- data/test/factories/organizations.rb +2 -2
- data/test/factories/regions.rb +1 -1
- data/test/factories/sub_organizations.rb +1 -1
- data/test/factories/suppressions.rb +109 -3
- data/test/factories/users.rb +65 -2
- data/test/test_helper.rb +9 -8
- metadata +41 -69
- data/bin/esp_console +0 -67
- data/rdoc/ActiveResource/Formats.html +0 -178
- data/rdoc/ActiveResource/PaginatedCollection.html +0 -912
- data/rdoc/ActiveResource.html +0 -182
- data/rdoc/ESP/Alert.html +0 -808
- data/rdoc/ESP/CloudTrailEvent.html +0 -377
- data/rdoc/ESP/ContactRequest.html +0 -368
- data/rdoc/ESP/CustomSignature.html +0 -748
- data/rdoc/ESP/Dashboard.html +0 -357
- data/rdoc/ESP/ExternalAccount.html +0 -567
- data/rdoc/ESP/Metadata.html +0 -411
- data/rdoc/ESP/Organization.html +0 -592
- data/rdoc/ESP/Region.html +0 -401
- data/rdoc/ESP/Report.html +0 -624
- data/rdoc/ESP/Service.html +0 -382
- data/rdoc/ESP/Signature.html +0 -557
- data/rdoc/ESP/Stat.html +0 -1780
- data/rdoc/ESP/StatCustomSignature.html +0 -1601
- data/rdoc/ESP/StatRegion.html +0 -1600
- data/rdoc/ESP/StatService.html +0 -1600
- data/rdoc/ESP/StatSignature.html +0 -1600
- data/rdoc/ESP/SubOrganization.html +0 -542
- data/rdoc/ESP/Suppression/Region.html +0 -456
- data/rdoc/ESP/Suppression/Signature.html +0 -472
- data/rdoc/ESP/Suppression/UniqueIdentifier.html +0 -419
- data/rdoc/ESP/Suppression.html +0 -651
- data/rdoc/ESP/Tag.html +0 -373
- data/rdoc/ESP/Team.html +0 -586
- data/rdoc/ESP/User.html +0 -485
- data/rdoc/ESP.html +0 -549
- data/rdoc/README_md.html +0 -503
- data/rdoc/created.rid +0 -31
- data/rdoc/images/add.png +0 -0
- data/rdoc/images/arrow_up.png +0 -0
- data/rdoc/images/brick.png +0 -0
- data/rdoc/images/brick_link.png +0 -0
- data/rdoc/images/bug.png +0 -0
- data/rdoc/images/bullet_black.png +0 -0
- data/rdoc/images/bullet_toggle_minus.png +0 -0
- data/rdoc/images/bullet_toggle_plus.png +0 -0
- data/rdoc/images/date.png +0 -0
- data/rdoc/images/delete.png +0 -0
- data/rdoc/images/find.png +0 -0
- data/rdoc/images/loadingAnimation.gif +0 -0
- data/rdoc/images/macFFBgHack.png +0 -0
- data/rdoc/images/package.png +0 -0
- data/rdoc/images/page_green.png +0 -0
- data/rdoc/images/page_white_text.png +0 -0
- data/rdoc/images/page_white_width.png +0 -0
- data/rdoc/images/plugin.png +0 -0
- data/rdoc/images/ruby.png +0 -0
- data/rdoc/images/tag_blue.png +0 -0
- data/rdoc/images/tag_green.png +0 -0
- data/rdoc/images/transparent.png +0 -0
- data/rdoc/images/wrench.png +0 -0
- data/rdoc/images/wrench_orange.png +0 -0
- data/rdoc/images/zoom.png +0 -0
- data/rdoc/index.html +0 -136
- data/rdoc/js/darkfish.js +0 -155
- data/rdoc/js/jquery.js +0 -4
- data/rdoc/js/navigation.js +0 -142
- data/rdoc/js/search.js +0 -94
- data/rdoc/js/search_index.js +0 -1
- data/rdoc/js/searcher.js +0 -228
- data/rdoc/rdoc.css +0 -595
- data/rdoc/table_of_contents.html +0 -942
|
@@ -1,912 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<html>
|
|
4
|
-
<head>
|
|
5
|
-
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
|
6
|
-
|
|
7
|
-
<title>class ActiveResource::PaginatedCollection - ESPSDK</title>
|
|
8
|
-
|
|
9
|
-
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet">
|
|
10
|
-
|
|
11
|
-
<script type="text/javascript">
|
|
12
|
-
var rdoc_rel_prefix = "../";
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
|
16
|
-
<script type="text/javascript" charset="utf-8" src="../js/navigation.js"></script>
|
|
17
|
-
<script type="text/javascript" charset="utf-8" src="../js/search_index.js"></script>
|
|
18
|
-
<script type="text/javascript" charset="utf-8" src="../js/search.js"></script>
|
|
19
|
-
<script type="text/javascript" charset="utf-8" src="../js/searcher.js"></script>
|
|
20
|
-
<script type="text/javascript" charset="utf-8" src="../js/darkfish.js"></script>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<body id="top" class="class">
|
|
24
|
-
<nav id="metadata">
|
|
25
|
-
<nav id="home-section" class="section">
|
|
26
|
-
<h3 class="section-header">
|
|
27
|
-
<a href="../index.html">Home</a>
|
|
28
|
-
<a href="../table_of_contents.html#classes">Classes</a>
|
|
29
|
-
<a href="../table_of_contents.html#methods">Methods</a>
|
|
30
|
-
</h3>
|
|
31
|
-
</nav>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<nav id="search-section" class="section project-section" class="initially-hidden">
|
|
35
|
-
<form action="#" method="get" accept-charset="utf-8">
|
|
36
|
-
<h3 class="section-header">
|
|
37
|
-
<input type="text" name="search" placeholder="Search" id="search-field"
|
|
38
|
-
title="Type to search, Up and Down to navigate, Enter to load">
|
|
39
|
-
</h3>
|
|
40
|
-
</form>
|
|
41
|
-
|
|
42
|
-
<ul id="search-results" class="initially-hidden"></ul>
|
|
43
|
-
</nav>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<div id="file-metadata">
|
|
49
|
-
<nav id="file-list-section" class="section">
|
|
50
|
-
<h3 class="section-header">Defined In</h3>
|
|
51
|
-
<ul>
|
|
52
|
-
<li>lib/esp/extensions/active_resource/paginated_collection.rb
|
|
53
|
-
</ul>
|
|
54
|
-
</nav>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div id="class-metadata">
|
|
60
|
-
|
|
61
|
-
<nav id="parent-class-section" class="section">
|
|
62
|
-
<h3 class="section-header">Parent</h3>
|
|
63
|
-
|
|
64
|
-
<p class="link">ActiveResource::Collection
|
|
65
|
-
|
|
66
|
-
</nav>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<!-- Method Quickref -->
|
|
71
|
-
<nav id="method-list-section" class="section">
|
|
72
|
-
<h3 class="section-header">Methods</h3>
|
|
73
|
-
|
|
74
|
-
<ul class="link-list">
|
|
75
|
-
|
|
76
|
-
<li ><a href="#method-i-current_page_number">#current_page_number</a>
|
|
77
|
-
|
|
78
|
-
<li ><a href="#method-i-first_page">#first_page</a>
|
|
79
|
-
|
|
80
|
-
<li ><a href="#method-i-first_page-21">#first_page!</a>
|
|
81
|
-
|
|
82
|
-
<li ><a href="#method-i-last_page">#last_page</a>
|
|
83
|
-
|
|
84
|
-
<li ><a href="#method-i-last_page-21">#last_page!</a>
|
|
85
|
-
|
|
86
|
-
<li ><a href="#method-i-last_page-3F">#last_page?</a>
|
|
87
|
-
|
|
88
|
-
<li ><a href="#method-i-last_page_number">#last_page_number</a>
|
|
89
|
-
|
|
90
|
-
<li ><a href="#method-i-next_page">#next_page</a>
|
|
91
|
-
|
|
92
|
-
<li ><a href="#method-i-next_page-21">#next_page!</a>
|
|
93
|
-
|
|
94
|
-
<li ><a href="#method-i-next_page-3F">#next_page?</a>
|
|
95
|
-
|
|
96
|
-
<li ><a href="#method-i-next_page_number">#next_page_number</a>
|
|
97
|
-
|
|
98
|
-
<li ><a href="#method-i-page">#page</a>
|
|
99
|
-
|
|
100
|
-
<li ><a href="#method-i-page-21">#page!</a>
|
|
101
|
-
|
|
102
|
-
<li ><a href="#method-i-previous_page">#previous_page</a>
|
|
103
|
-
|
|
104
|
-
<li ><a href="#method-i-previous_page-21">#previous_page!</a>
|
|
105
|
-
|
|
106
|
-
<li ><a href="#method-i-previous_page-3F">#previous_page?</a>
|
|
107
|
-
|
|
108
|
-
<li ><a href="#method-i-previous_page_number">#previous_page_number</a>
|
|
109
|
-
|
|
110
|
-
</ul>
|
|
111
|
-
</nav>
|
|
112
|
-
|
|
113
|
-
</div>
|
|
114
|
-
|
|
115
|
-
<div id="project-metadata">
|
|
116
|
-
<nav id="fileindex-section" class="section project-section">
|
|
117
|
-
<h3 class="section-header">Pages</h3>
|
|
118
|
-
|
|
119
|
-
<ul>
|
|
120
|
-
|
|
121
|
-
<li class="file"><a href="../README_md.html">README</a>
|
|
122
|
-
|
|
123
|
-
</ul>
|
|
124
|
-
</nav>
|
|
125
|
-
|
|
126
|
-
<nav id="classindex-section" class="section project-section">
|
|
127
|
-
<h3 class="section-header">Class and Module Index</h3>
|
|
128
|
-
|
|
129
|
-
<ul class="link-list">
|
|
130
|
-
|
|
131
|
-
<li><a href="../ActiveResource.html">ActiveResource</a>
|
|
132
|
-
|
|
133
|
-
<li><a href="../ActiveResource/Formats.html">ActiveResource::Formats</a>
|
|
134
|
-
|
|
135
|
-
<li><a href="../ActiveResource/PaginatedCollection.html">ActiveResource::PaginatedCollection</a>
|
|
136
|
-
|
|
137
|
-
<li><a href="../ESP.html">ESP</a>
|
|
138
|
-
|
|
139
|
-
<li><a href="../ESP/Alert.html">ESP::Alert</a>
|
|
140
|
-
|
|
141
|
-
<li><a href="../ESP/CloudTrailEvent.html">ESP::CloudTrailEvent</a>
|
|
142
|
-
|
|
143
|
-
<li><a href="../ESP/ContactRequest.html">ESP::ContactRequest</a>
|
|
144
|
-
|
|
145
|
-
<li><a href="../ESP/CustomSignature.html">ESP::CustomSignature</a>
|
|
146
|
-
|
|
147
|
-
<li><a href="../ESP/Dashboard.html">ESP::Dashboard</a>
|
|
148
|
-
|
|
149
|
-
<li><a href="../ESP/ExternalAccount.html">ESP::ExternalAccount</a>
|
|
150
|
-
|
|
151
|
-
<li><a href="../ESP/Metadata.html">ESP::Metadata</a>
|
|
152
|
-
|
|
153
|
-
<li><a href="../ESP/Organization.html">ESP::Organization</a>
|
|
154
|
-
|
|
155
|
-
<li><a href="../ESP/Region.html">ESP::Region</a>
|
|
156
|
-
|
|
157
|
-
<li><a href="../ESP/Report.html">ESP::Report</a>
|
|
158
|
-
|
|
159
|
-
<li><a href="../ESP/Service.html">ESP::Service</a>
|
|
160
|
-
|
|
161
|
-
<li><a href="../ESP/Signature.html">ESP::Signature</a>
|
|
162
|
-
|
|
163
|
-
<li><a href="../ESP/Stat.html">ESP::Stat</a>
|
|
164
|
-
|
|
165
|
-
<li><a href="../ESP/StatCustomSignature.html">ESP::StatCustomSignature</a>
|
|
166
|
-
|
|
167
|
-
<li><a href="../ESP/StatRegion.html">ESP::StatRegion</a>
|
|
168
|
-
|
|
169
|
-
<li><a href="../ESP/StatService.html">ESP::StatService</a>
|
|
170
|
-
|
|
171
|
-
<li><a href="../ESP/StatSignature.html">ESP::StatSignature</a>
|
|
172
|
-
|
|
173
|
-
<li><a href="../ESP/SubOrganization.html">ESP::SubOrganization</a>
|
|
174
|
-
|
|
175
|
-
<li><a href="../ESP/Suppression.html">ESP::Suppression</a>
|
|
176
|
-
|
|
177
|
-
<li><a href="../ESP/Suppression/Region.html">ESP::Suppression::Region</a>
|
|
178
|
-
|
|
179
|
-
<li><a href="../ESP/Suppression/Signature.html">ESP::Suppression::Signature</a>
|
|
180
|
-
|
|
181
|
-
<li><a href="../ESP/Suppression/UniqueIdentifier.html">ESP::Suppression::UniqueIdentifier</a>
|
|
182
|
-
|
|
183
|
-
<li><a href="../ESP/Tag.html">ESP::Tag</a>
|
|
184
|
-
|
|
185
|
-
<li><a href="../ESP/Team.html">ESP::Team</a>
|
|
186
|
-
|
|
187
|
-
<li><a href="../ESP/User.html">ESP::User</a>
|
|
188
|
-
|
|
189
|
-
</ul>
|
|
190
|
-
</nav>
|
|
191
|
-
|
|
192
|
-
</div>
|
|
193
|
-
</nav>
|
|
194
|
-
|
|
195
|
-
<div id="documentation">
|
|
196
|
-
<h1 class="class">class ActiveResource::PaginatedCollection</h1>
|
|
197
|
-
|
|
198
|
-
<div id="description" class="description">
|
|
199
|
-
|
|
200
|
-
<p>Provides a mean to call the Evident.io API to easily retrieve paginated
|
|
201
|
-
data</p>
|
|
202
|
-
|
|
203
|
-
</div><!-- description -->
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<section id="5Buntitled-5D" class="documentation-section">
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<!-- Methods -->
|
|
218
|
-
|
|
219
|
-
<section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
|
|
220
|
-
<h3 class="section-header">Public Instance Methods</h3>
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<div id="method-i-current_page_number" class="method-detail ">
|
|
224
|
-
|
|
225
|
-
<div class="method-heading">
|
|
226
|
-
<span class="method-name">current_page_number</span><span
|
|
227
|
-
class="method-args">()</span>
|
|
228
|
-
|
|
229
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
230
|
-
|
|
231
|
-
</div>
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
<div class="method-description">
|
|
235
|
-
|
|
236
|
-
<p>The current page number of data.</p>
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
<div class="method-source-code" id="current_page_number-source">
|
|
242
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 146</span>
|
|
243
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">current_page_number</span>
|
|
244
|
-
(<span class="ruby-identifier">previous_page_number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>).<span class="ruby-identifier">to_s</span>
|
|
245
|
-
<span class="ruby-keyword">end</span></pre>
|
|
246
|
-
</div><!-- current_page_number-source -->
|
|
247
|
-
|
|
248
|
-
</div>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
</div><!-- current_page_number-method -->
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
<div id="method-i-first_page" class="method-detail ">
|
|
257
|
-
|
|
258
|
-
<div class="method-heading">
|
|
259
|
-
<span class="method-name">first_page</span><span
|
|
260
|
-
class="method-args">()</span>
|
|
261
|
-
|
|
262
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
263
|
-
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
<div class="method-description">
|
|
268
|
-
|
|
269
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
270
|
-
with the first page of results.</p>
|
|
271
|
-
|
|
272
|
-
<p>Returns self when on the first page and no API call is made.</p>
|
|
273
|
-
|
|
274
|
-
<h4 id="method-i-first_page-label-Example">Example<span><a href="#method-i-first_page-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
275
|
-
|
|
276
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
277
|
-
<span class="ruby-identifier">first_page</span> = <span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">first_page</span>
|
|
278
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
279
|
-
<span class="ruby-identifier">first_page</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 1</span>
|
|
280
|
-
</pre>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
<div class="method-source-code" id="first_page-source">
|
|
286
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 28</span>
|
|
287
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">first_page</span>
|
|
288
|
-
<span class="ruby-identifier">previous_page?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">from</span><span class="ruby-operator">:</span> <span class="ruby-identifier">from</span>, <span class="ruby-identifier">params</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">page</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">number</span><span class="ruby-operator">:</span> <span class="ruby-value">1</span> } }) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
|
|
289
|
-
<span class="ruby-keyword">end</span></pre>
|
|
290
|
-
</div><!-- first_page-source -->
|
|
291
|
-
|
|
292
|
-
</div>
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
</div><!-- first_page-method -->
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
<div id="method-i-first_page-21" class="method-detail ">
|
|
301
|
-
|
|
302
|
-
<div class="method-heading">
|
|
303
|
-
<span class="method-name">first_page!</span><span
|
|
304
|
-
class="method-args">()</span>
|
|
305
|
-
|
|
306
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
307
|
-
|
|
308
|
-
</div>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
<div class="method-description">
|
|
312
|
-
|
|
313
|
-
<p>Updates the existing <a
|
|
314
|
-
href="PaginatedCollection.html">PaginatedCollection</a> object with the
|
|
315
|
-
first page of data when not on the first page.</p>
|
|
316
|
-
|
|
317
|
-
<h4 id="method-i-first_page-21-label-Example">Example<span><a href="#method-i-first_page-21-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
318
|
-
|
|
319
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
320
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">first_page!</span>
|
|
321
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 1</span>
|
|
322
|
-
</pre>
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
<div class="method-source-code" id="first_page-21-source">
|
|
328
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 38</span>
|
|
329
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">first_page!</span>
|
|
330
|
-
<span class="ruby-identifier">first_page</span>.<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span> <span class="ruby-identifier">update_self</span>(<span class="ruby-identifier">page</span>) }
|
|
331
|
-
<span class="ruby-keyword">end</span></pre>
|
|
332
|
-
</div><!-- first_page-21-source -->
|
|
333
|
-
|
|
334
|
-
</div>
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
</div><!-- first_page-21-method -->
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
<div id="method-i-last_page" class="method-detail ">
|
|
343
|
-
|
|
344
|
-
<div class="method-heading">
|
|
345
|
-
<span class="method-name">last_page</span><span
|
|
346
|
-
class="method-args">()</span>
|
|
347
|
-
|
|
348
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
349
|
-
|
|
350
|
-
</div>
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
<div class="method-description">
|
|
354
|
-
|
|
355
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
356
|
-
with the last page of results.</p>
|
|
357
|
-
|
|
358
|
-
<p>Returns self when on the last page and no API call is made.</p>
|
|
359
|
-
|
|
360
|
-
<h4 id="method-i-last_page-label-Example">Example<span><a href="#method-i-last_page-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
361
|
-
|
|
362
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
363
|
-
<span class="ruby-identifier">last_page</span> = <span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">last_page</span>
|
|
364
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
365
|
-
<span class="ruby-identifier">last_page</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 25</span>
|
|
366
|
-
</pre>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
<div class="method-source-code" id="last_page-source">
|
|
372
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 97</span>
|
|
373
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">last_page</span>
|
|
374
|
-
<span class="ruby-operator">!</span><span class="ruby-identifier">last_page?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">from</span><span class="ruby-operator">:</span> <span class="ruby-identifier">from</span>, <span class="ruby-identifier">params</span><span class="ruby-operator">:</span> <span class="ruby-identifier">last_page_params</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
|
|
375
|
-
<span class="ruby-keyword">end</span></pre>
|
|
376
|
-
</div><!-- last_page-source -->
|
|
377
|
-
|
|
378
|
-
</div>
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
</div><!-- last_page-method -->
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
<div id="method-i-last_page-21" class="method-detail ">
|
|
387
|
-
|
|
388
|
-
<div class="method-heading">
|
|
389
|
-
<span class="method-name">last_page!</span><span
|
|
390
|
-
class="method-args">()</span>
|
|
391
|
-
|
|
392
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
393
|
-
|
|
394
|
-
</div>
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
<div class="method-description">
|
|
398
|
-
|
|
399
|
-
<p>Updates the existing <a
|
|
400
|
-
href="PaginatedCollection.html">PaginatedCollection</a> object with the
|
|
401
|
-
last page of data when not on the last page.</p>
|
|
402
|
-
|
|
403
|
-
<h4 id="method-i-last_page-21-label-Example">Example<span><a href="#method-i-last_page-21-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
404
|
-
|
|
405
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
406
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">last_page!</span>
|
|
407
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 25</span>
|
|
408
|
-
</pre>
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
<div class="method-source-code" id="last_page-21-source">
|
|
414
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 107</span>
|
|
415
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">last_page!</span>
|
|
416
|
-
<span class="ruby-identifier">last_page</span>.<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span> <span class="ruby-identifier">update_self</span>(<span class="ruby-identifier">page</span>) }
|
|
417
|
-
<span class="ruby-keyword">end</span></pre>
|
|
418
|
-
</div><!-- last_page-21-source -->
|
|
419
|
-
|
|
420
|
-
</div>
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
</div><!-- last_page-21-method -->
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
<div id="method-i-last_page-3F" class="method-detail ">
|
|
429
|
-
|
|
430
|
-
<div class="method-heading">
|
|
431
|
-
<span class="method-name">last_page?</span><span
|
|
432
|
-
class="method-args">()</span>
|
|
433
|
-
|
|
434
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
435
|
-
|
|
436
|
-
</div>
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
<div class="method-description">
|
|
440
|
-
|
|
441
|
-
<p>Returns whether or not the collection is on the last page.</p>
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
<div class="method-source-code" id="last_page-3F-source">
|
|
447
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 176</span>
|
|
448
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">last_page?</span>
|
|
449
|
-
<span class="ruby-identifier">last_page_number</span>.<span class="ruby-identifier">nil?</span>
|
|
450
|
-
<span class="ruby-keyword">end</span></pre>
|
|
451
|
-
</div><!-- last_page-3F-source -->
|
|
452
|
-
|
|
453
|
-
</div>
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
</div><!-- last_page-3F-method -->
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
<div id="method-i-last_page_number" class="method-detail ">
|
|
462
|
-
|
|
463
|
-
<div class="method-heading">
|
|
464
|
-
<span class="method-name">last_page_number</span><span
|
|
465
|
-
class="method-args">()</span>
|
|
466
|
-
|
|
467
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
468
|
-
|
|
469
|
-
</div>
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
<div class="method-description">
|
|
473
|
-
|
|
474
|
-
<p>The last page number of data.</p>
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
<div class="method-source-code" id="last_page_number-source">
|
|
480
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 161</span>
|
|
481
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">last_page_number</span>
|
|
482
|
-
<span class="ruby-constant">Hash</span>(<span class="ruby-identifier">last_page_params</span>).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'page'</span>, {}).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'number'</span>, <span class="ruby-keyword">nil</span>)
|
|
483
|
-
<span class="ruby-keyword">end</span></pre>
|
|
484
|
-
</div><!-- last_page_number-source -->
|
|
485
|
-
|
|
486
|
-
</div>
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
</div><!-- last_page_number-method -->
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
<div id="method-i-next_page" class="method-detail ">
|
|
495
|
-
|
|
496
|
-
<div class="method-heading">
|
|
497
|
-
<span class="method-name">next_page</span><span
|
|
498
|
-
class="method-args">()</span>
|
|
499
|
-
|
|
500
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
501
|
-
|
|
502
|
-
</div>
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
<div class="method-description">
|
|
506
|
-
|
|
507
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
508
|
-
with the next page of results.</p>
|
|
509
|
-
|
|
510
|
-
<p>Returns self when on the last page and no API call is made.</p>
|
|
511
|
-
|
|
512
|
-
<h4 id="method-i-next_page-label-Example">Example<span><a href="#method-i-next_page-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
513
|
-
|
|
514
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
515
|
-
<span class="ruby-identifier">next_page</span> = <span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">next_page</span>
|
|
516
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
517
|
-
<span class="ruby-identifier">next_page</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 6</span>
|
|
518
|
-
</pre>
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
<div class="method-source-code" id="next_page-source">
|
|
524
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 74</span>
|
|
525
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">next_page</span>
|
|
526
|
-
<span class="ruby-identifier">next_page?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">from</span><span class="ruby-operator">:</span> <span class="ruby-identifier">from</span>, <span class="ruby-identifier">params</span><span class="ruby-operator">:</span> <span class="ruby-identifier">next_page_params</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
|
|
527
|
-
<span class="ruby-keyword">end</span></pre>
|
|
528
|
-
</div><!-- next_page-source -->
|
|
529
|
-
|
|
530
|
-
</div>
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
</div><!-- next_page-method -->
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
<div id="method-i-next_page-21" class="method-detail ">
|
|
539
|
-
|
|
540
|
-
<div class="method-heading">
|
|
541
|
-
<span class="method-name">next_page!</span><span
|
|
542
|
-
class="method-args">()</span>
|
|
543
|
-
|
|
544
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
545
|
-
|
|
546
|
-
</div>
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
<div class="method-description">
|
|
550
|
-
|
|
551
|
-
<p>Updates the existing <a
|
|
552
|
-
href="PaginatedCollection.html">PaginatedCollection</a> object with the
|
|
553
|
-
last page of data when not on the last page.</p>
|
|
554
|
-
|
|
555
|
-
<h4 id="method-i-next_page-21-label-Example">Example<span><a href="#method-i-next_page-21-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
556
|
-
|
|
557
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
558
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">next_page!</span>
|
|
559
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 6</span>
|
|
560
|
-
</pre>
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
<div class="method-source-code" id="next_page-21-source">
|
|
566
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 84</span>
|
|
567
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">next_page!</span>
|
|
568
|
-
<span class="ruby-identifier">next_page</span>.<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span> <span class="ruby-identifier">update_self</span>(<span class="ruby-identifier">page</span>) }
|
|
569
|
-
<span class="ruby-keyword">end</span></pre>
|
|
570
|
-
</div><!-- next_page-21-source -->
|
|
571
|
-
|
|
572
|
-
</div>
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
</div><!-- next_page-21-method -->
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
<div id="method-i-next_page-3F" class="method-detail ">
|
|
581
|
-
|
|
582
|
-
<div class="method-heading">
|
|
583
|
-
<span class="method-name">next_page?</span><span
|
|
584
|
-
class="method-args">()</span>
|
|
585
|
-
|
|
586
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
587
|
-
|
|
588
|
-
</div>
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
<div class="method-description">
|
|
592
|
-
|
|
593
|
-
<p>Returns whether or not there is a next page of data in the collection.</p>
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
<div class="method-source-code" id="next_page-3F-source">
|
|
599
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 171</span>
|
|
600
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">next_page?</span>
|
|
601
|
-
<span class="ruby-operator">!</span><span class="ruby-identifier">next_page_number</span>.<span class="ruby-identifier">nil?</span>
|
|
602
|
-
<span class="ruby-keyword">end</span></pre>
|
|
603
|
-
</div><!-- next_page-3F-source -->
|
|
604
|
-
|
|
605
|
-
</div>
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
</div><!-- next_page-3F-method -->
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
<div id="method-i-next_page_number" class="method-detail ">
|
|
614
|
-
|
|
615
|
-
<div class="method-heading">
|
|
616
|
-
<span class="method-name">next_page_number</span><span
|
|
617
|
-
class="method-args">()</span>
|
|
618
|
-
|
|
619
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
620
|
-
|
|
621
|
-
</div>
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
<div class="method-description">
|
|
625
|
-
|
|
626
|
-
<p>The next page number of data.</p>
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
<div class="method-source-code" id="next_page_number-source">
|
|
632
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 156</span>
|
|
633
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">next_page_number</span>
|
|
634
|
-
<span class="ruby-constant">Hash</span>(<span class="ruby-identifier">next_page_params</span>).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'page'</span>, {}).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'number'</span>, <span class="ruby-keyword">nil</span>)
|
|
635
|
-
<span class="ruby-keyword">end</span></pre>
|
|
636
|
-
</div><!-- next_page_number-source -->
|
|
637
|
-
|
|
638
|
-
</div>
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
</div><!-- next_page_number-method -->
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
<div id="method-i-page" class="method-detail ">
|
|
647
|
-
|
|
648
|
-
<div class="method-heading">
|
|
649
|
-
<span class="method-name">page</span><span
|
|
650
|
-
class="method-args">(page_number = nil)</span>
|
|
651
|
-
|
|
652
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
653
|
-
|
|
654
|
-
</div>
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
<div class="method-description">
|
|
658
|
-
|
|
659
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
660
|
-
with the <code>page_number</code> page of data.</p>
|
|
661
|
-
|
|
662
|
-
<p>Returns self when <code>page_number</code> == <a
|
|
663
|
-
href="PaginatedCollection.html#method-i-current_page_number">current_page_number</a></p>
|
|
664
|
-
|
|
665
|
-
<h4 id="method-i-page-label-Attribute">Attribute<span><a href="#method-i-page-label-Attribute">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
666
|
-
|
|
667
|
-
<p><code>page_number</code> - The page number of the data wanted.
|
|
668
|
-
<code>page_number</code> must be between 1 and <a
|
|
669
|
-
href="PaginatedCollection.html#method-i-last_page_number">last_page_number</a>.</p>
|
|
670
|
-
|
|
671
|
-
<h4 id="method-i-page-label-Example">Example<span><a href="#method-i-page-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
672
|
-
|
|
673
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
674
|
-
<span class="ruby-identifier">page</span> = <span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">page</span>(<span class="ruby-value">2</span>)
|
|
675
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
676
|
-
<span class="ruby-identifier">page</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 2</span>
|
|
677
|
-
</pre>
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
<div class="method-source-code" id="page-source">
|
|
683
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 124</span>
|
|
684
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">page</span>(<span class="ruby-identifier">page_number</span> = <span class="ruby-keyword">nil</span>)
|
|
685
|
-
<span class="ruby-identifier">fail</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"You must supply a page number."</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">page_number</span>.<span class="ruby-identifier">present?</span>
|
|
686
|
-
<span class="ruby-identifier">fail</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"Page number cannot be less than 1."</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">page_number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator"><</span> <span class="ruby-value">1</span>
|
|
687
|
-
<span class="ruby-identifier">fail</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">"Page number cannot be greater than the last page number."</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">page_number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">></span> <span class="ruby-identifier">last_page_number</span>.<span class="ruby-identifier">to_i</span>
|
|
688
|
-
<span class="ruby-identifier">page_number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">current_page_number</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">from</span><span class="ruby-operator">:</span> <span class="ruby-identifier">from</span>, <span class="ruby-identifier">params</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">page</span><span class="ruby-operator">:</span> { <span class="ruby-identifier">number</span><span class="ruby-operator">:</span> <span class="ruby-identifier">page_number</span>, <span class="ruby-identifier">size</span><span class="ruby-operator">:</span> (<span class="ruby-identifier">next_page_params</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">previous_page_params</span>)[<span class="ruby-string">'page'</span>][<span class="ruby-string">'size'</span>] } }) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
|
|
689
|
-
<span class="ruby-keyword">end</span></pre>
|
|
690
|
-
</div><!-- page-source -->
|
|
691
|
-
|
|
692
|
-
</div>
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
</div><!-- page-method -->
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
<div id="method-i-page-21" class="method-detail ">
|
|
701
|
-
|
|
702
|
-
<div class="method-heading">
|
|
703
|
-
<span class="method-name">page!</span><span
|
|
704
|
-
class="method-args">(page_number)</span>
|
|
705
|
-
|
|
706
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
707
|
-
|
|
708
|
-
</div>
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
<div class="method-description">
|
|
712
|
-
|
|
713
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
714
|
-
with the <code>page_number</code> page of data when not already on page
|
|
715
|
-
<code>page_number</code>.</p>
|
|
716
|
-
|
|
717
|
-
<h4 id="method-i-page-21-label-Attribute">Attribute<span><a href="#method-i-page-21-label-Attribute">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
718
|
-
|
|
719
|
-
<p><code>page_number</code> - The page number of the data wanted.
|
|
720
|
-
<code>page_number</code> must be between 1 and <a
|
|
721
|
-
href="PaginatedCollection.html#method-i-last_page_number">last_page_number</a>.</p>
|
|
722
|
-
|
|
723
|
-
<h4 id="method-i-page-21-label-Example">Example<span><a href="#method-i-page-21-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
724
|
-
|
|
725
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
726
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">page!</span>(<span class="ruby-value">2</span>)
|
|
727
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 2</span>
|
|
728
|
-
</pre>
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
<div class="method-source-code" id="page-21-source">
|
|
734
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 141</span>
|
|
735
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">page!</span>(<span class="ruby-identifier">page_number</span>)
|
|
736
|
-
<span class="ruby-identifier">page</span>(<span class="ruby-identifier">page_number</span>).<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span> <span class="ruby-identifier">update_self</span>(<span class="ruby-identifier">page</span>) }
|
|
737
|
-
<span class="ruby-keyword">end</span></pre>
|
|
738
|
-
</div><!-- page-21-source -->
|
|
739
|
-
|
|
740
|
-
</div>
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
</div><!-- page-21-method -->
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
<div id="method-i-previous_page" class="method-detail ">
|
|
749
|
-
|
|
750
|
-
<div class="method-heading">
|
|
751
|
-
<span class="method-name">previous_page</span><span
|
|
752
|
-
class="method-args">()</span>
|
|
753
|
-
|
|
754
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
755
|
-
|
|
756
|
-
</div>
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
<div class="method-description">
|
|
760
|
-
|
|
761
|
-
<p>Returns a new <a href="PaginatedCollection.html">PaginatedCollection</a>
|
|
762
|
-
with the previous page of results.</p>
|
|
763
|
-
|
|
764
|
-
<p>Returns self when on the first page and no API call is made.</p>
|
|
765
|
-
|
|
766
|
-
<h4 id="method-i-previous_page-label-Example">Example<span><a href="#method-i-previous_page-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
767
|
-
|
|
768
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
769
|
-
<span class="ruby-identifier">previous_page</span> = <span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">previous_page</span>
|
|
770
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
771
|
-
<span class="ruby-identifier">previous_page</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 4</span>
|
|
772
|
-
</pre>
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
<div class="method-source-code" id="previous_page-source">
|
|
778
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 51</span>
|
|
779
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">previous_page</span>
|
|
780
|
-
<span class="ruby-identifier">previous_page?</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">resource_class</span>.<span class="ruby-identifier">all</span>(<span class="ruby-identifier">from</span><span class="ruby-operator">:</span> <span class="ruby-identifier">from</span>, <span class="ruby-identifier">params</span><span class="ruby-operator">:</span> <span class="ruby-identifier">previous_page_params</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword">self</span>
|
|
781
|
-
<span class="ruby-keyword">end</span></pre>
|
|
782
|
-
</div><!-- previous_page-source -->
|
|
783
|
-
|
|
784
|
-
</div>
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
</div><!-- previous_page-method -->
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
<div id="method-i-previous_page-21" class="method-detail ">
|
|
793
|
-
|
|
794
|
-
<div class="method-heading">
|
|
795
|
-
<span class="method-name">previous_page!</span><span
|
|
796
|
-
class="method-args">()</span>
|
|
797
|
-
|
|
798
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
799
|
-
|
|
800
|
-
</div>
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
<div class="method-description">
|
|
804
|
-
|
|
805
|
-
<p>Updates the existing <a
|
|
806
|
-
href="PaginatedCollection.html">PaginatedCollection</a> object with the
|
|
807
|
-
previous page of data when not on the first page.</p>
|
|
808
|
-
|
|
809
|
-
<h4 id="method-i-previous_page-21-label-Example">Example<span><a href="#method-i-previous_page-21-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
|
810
|
-
|
|
811
|
-
<pre class="ruby"><span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 5</span>
|
|
812
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">previous_page!</span>
|
|
813
|
-
<span class="ruby-identifier">alerts</span>.<span class="ruby-identifier">current_page_number</span> <span class="ruby-comment"># => 4</span>
|
|
814
|
-
</pre>
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
<div class="method-source-code" id="previous_page-21-source">
|
|
820
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 61</span>
|
|
821
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">previous_page!</span>
|
|
822
|
-
<span class="ruby-identifier">previous_page</span>.<span class="ruby-identifier">tap</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">page</span><span class="ruby-operator">|</span> <span class="ruby-identifier">update_self</span>(<span class="ruby-identifier">page</span>) }
|
|
823
|
-
<span class="ruby-keyword">end</span></pre>
|
|
824
|
-
</div><!-- previous_page-21-source -->
|
|
825
|
-
|
|
826
|
-
</div>
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
</div><!-- previous_page-21-method -->
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
<div id="method-i-previous_page-3F" class="method-detail ">
|
|
835
|
-
|
|
836
|
-
<div class="method-heading">
|
|
837
|
-
<span class="method-name">previous_page?</span><span
|
|
838
|
-
class="method-args">()</span>
|
|
839
|
-
|
|
840
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
841
|
-
|
|
842
|
-
</div>
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
<div class="method-description">
|
|
846
|
-
|
|
847
|
-
<p>Returns whether or not there is a previous page of data in the collection.</p>
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
<div class="method-source-code" id="previous_page-3F-source">
|
|
853
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 166</span>
|
|
854
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">previous_page?</span>
|
|
855
|
-
<span class="ruby-operator">!</span><span class="ruby-identifier">previous_page_number</span>.<span class="ruby-identifier">nil?</span>
|
|
856
|
-
<span class="ruby-keyword">end</span></pre>
|
|
857
|
-
</div><!-- previous_page-3F-source -->
|
|
858
|
-
|
|
859
|
-
</div>
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
</div><!-- previous_page-3F-method -->
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
<div id="method-i-previous_page_number" class="method-detail ">
|
|
868
|
-
|
|
869
|
-
<div class="method-heading">
|
|
870
|
-
<span class="method-name">previous_page_number</span><span
|
|
871
|
-
class="method-args">()</span>
|
|
872
|
-
|
|
873
|
-
<span class="method-click-advice">click to toggle source</span>
|
|
874
|
-
|
|
875
|
-
</div>
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
<div class="method-description">
|
|
879
|
-
|
|
880
|
-
<p>The previous page number of data.</p>
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
<div class="method-source-code" id="previous_page_number-source">
|
|
886
|
-
<pre><span class="ruby-comment"># File lib/esp/extensions/active_resource/paginated_collection.rb, line 151</span>
|
|
887
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">previous_page_number</span>
|
|
888
|
-
<span class="ruby-constant">Hash</span>(<span class="ruby-identifier">previous_page_params</span>).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'page'</span>, {}).<span class="ruby-identifier">fetch</span>(<span class="ruby-string">'number'</span>, <span class="ruby-keyword">nil</span>)
|
|
889
|
-
<span class="ruby-keyword">end</span></pre>
|
|
890
|
-
</div><!-- previous_page_number-source -->
|
|
891
|
-
|
|
892
|
-
</div>
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
</div><!-- previous_page_number-method -->
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
</section><!-- public-instance-method-details -->
|
|
901
|
-
|
|
902
|
-
</section><!-- 5Buntitled-5D -->
|
|
903
|
-
|
|
904
|
-
</div><!-- documentation -->
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
<footer id="validator-badges">
|
|
908
|
-
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
|
909
|
-
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
|
910
|
-
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
|
911
|
-
</footer>
|
|
912
|
-
|