jsonapi_compliable 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +11 -3
  4. data/.yardopts +1 -0
  5. data/README.md +10 -1
  6. data/Rakefile +1 -0
  7. data/docs/JsonapiCompliable.html +202 -0
  8. data/docs/JsonapiCompliable/Adapters.html +119 -0
  9. data/docs/JsonapiCompliable/Adapters/Abstract.html +2285 -0
  10. data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +2151 -0
  11. data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +582 -0
  12. data/docs/JsonapiCompliable/Adapters/Null.html +1682 -0
  13. data/docs/JsonapiCompliable/Base.html +1395 -0
  14. data/docs/JsonapiCompliable/Deserializer.html +835 -0
  15. data/docs/JsonapiCompliable/Errors.html +115 -0
  16. data/docs/JsonapiCompliable/Errors/BadFilter.html +124 -0
  17. data/docs/JsonapiCompliable/Errors/StatNotFound.html +266 -0
  18. data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +264 -0
  19. data/docs/JsonapiCompliable/Errors/ValidationError.html +124 -0
  20. data/docs/JsonapiCompliable/Extensions.html +117 -0
  21. data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +212 -0
  22. data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +229 -0
  23. data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +242 -0
  24. data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +237 -0
  25. data/docs/JsonapiCompliable/Query.html +1099 -0
  26. data/docs/JsonapiCompliable/Rails.html +211 -0
  27. data/docs/JsonapiCompliable/Resource.html +5241 -0
  28. data/docs/JsonapiCompliable/Scope.html +703 -0
  29. data/docs/JsonapiCompliable/Scoping.html +117 -0
  30. data/docs/JsonapiCompliable/Scoping/Base.html +843 -0
  31. data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +318 -0
  32. data/docs/JsonapiCompliable/Scoping/ExtraFields.html +301 -0
  33. data/docs/JsonapiCompliable/Scoping/Filter.html +313 -0
  34. data/docs/JsonapiCompliable/Scoping/Filterable.html +364 -0
  35. data/docs/JsonapiCompliable/Scoping/Paginate.html +613 -0
  36. data/docs/JsonapiCompliable/Scoping/Sort.html +454 -0
  37. data/docs/JsonapiCompliable/SerializableTempId.html +216 -0
  38. data/docs/JsonapiCompliable/Sideload.html +2484 -0
  39. data/docs/JsonapiCompliable/Stats.html +117 -0
  40. data/docs/JsonapiCompliable/Stats/DSL.html +999 -0
  41. data/docs/JsonapiCompliable/Stats/Payload.html +391 -0
  42. data/docs/JsonapiCompliable/Util.html +117 -0
  43. data/docs/JsonapiCompliable/Util/FieldParams.html +228 -0
  44. data/docs/JsonapiCompliable/Util/Hash.html +471 -0
  45. data/docs/JsonapiCompliable/Util/IncludeParams.html +299 -0
  46. data/docs/JsonapiCompliable/Util/Persistence.html +435 -0
  47. data/docs/JsonapiCompliable/Util/RelationshipPayload.html +563 -0
  48. data/docs/JsonapiCompliable/Util/RenderOptions.html +250 -0
  49. data/docs/JsonapiCompliable/Util/ValidationResponse.html +532 -0
  50. data/docs/_index.html +527 -0
  51. data/docs/class_list.html +51 -0
  52. data/docs/css/common.css +1 -0
  53. data/docs/css/full_list.css +58 -0
  54. data/docs/css/style.css +492 -0
  55. data/docs/file.README.html +99 -0
  56. data/docs/file_list.html +56 -0
  57. data/docs/frames.html +17 -0
  58. data/docs/index.html +99 -0
  59. data/docs/js/app.js +248 -0
  60. data/docs/js/full_list.js +216 -0
  61. data/docs/js/jquery.js +4 -0
  62. data/docs/method_list.html +1731 -0
  63. data/docs/top-level-namespace.html +110 -0
  64. data/gemfiles/rails_5.gemfile +1 -1
  65. data/lib/jsonapi_compliable/adapters/abstract.rb +267 -4
  66. data/lib/jsonapi_compliable/adapters/active_record.rb +23 -1
  67. data/lib/jsonapi_compliable/adapters/null.rb +43 -3
  68. data/lib/jsonapi_compliable/base.rb +182 -33
  69. data/lib/jsonapi_compliable/deserializer.rb +90 -21
  70. data/lib/jsonapi_compliable/extensions/boolean_attribute.rb +12 -0
  71. data/lib/jsonapi_compliable/extensions/extra_attribute.rb +32 -0
  72. data/lib/jsonapi_compliable/extensions/temp_id.rb +11 -0
  73. data/lib/jsonapi_compliable/query.rb +94 -2
  74. data/lib/jsonapi_compliable/rails.rb +8 -0
  75. data/lib/jsonapi_compliable/resource.rb +548 -11
  76. data/lib/jsonapi_compliable/scope.rb +43 -1
  77. data/lib/jsonapi_compliable/scoping/base.rb +59 -8
  78. data/lib/jsonapi_compliable/scoping/default_filter.rb +33 -0
  79. data/lib/jsonapi_compliable/scoping/extra_fields.rb +33 -0
  80. data/lib/jsonapi_compliable/scoping/filter.rb +29 -2
  81. data/lib/jsonapi_compliable/scoping/filterable.rb +4 -0
  82. data/lib/jsonapi_compliable/scoping/paginate.rb +33 -0
  83. data/lib/jsonapi_compliable/scoping/sort.rb +18 -0
  84. data/lib/jsonapi_compliable/sideload.rb +229 -1
  85. data/lib/jsonapi_compliable/stats/dsl.rb +44 -0
  86. data/lib/jsonapi_compliable/stats/payload.rb +20 -0
  87. data/lib/jsonapi_compliable/util/field_params.rb +1 -0
  88. data/lib/jsonapi_compliable/util/hash.rb +18 -0
  89. data/lib/jsonapi_compliable/util/include_params.rb +22 -0
  90. data/lib/jsonapi_compliable/util/persistence.rb +13 -3
  91. data/lib/jsonapi_compliable/util/relationship_payload.rb +2 -0
  92. data/lib/jsonapi_compliable/util/render_options.rb +2 -0
  93. data/lib/jsonapi_compliable/util/validation_response.rb +16 -0
  94. data/lib/jsonapi_compliable/version.rb +1 -1
  95. metadata +60 -5
  96. data/gemfiles/rails_4.gemfile.lock +0 -208
  97. data/gemfiles/rails_5.gemfile.lock +0 -212
  98. data/lib/jsonapi_compliable/write.rb +0 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 581276bd4edc803209be48bec1f03a72ffad2bd4
4
- data.tar.gz: bda4a188aaecfab0a92b7f5bd70c45b5d7265420
3
+ metadata.gz: c47cd76b9843919c4e5c2c1786fd300944c04fd4
4
+ data.tar.gz: 71c36dd06f92f570aaf88b8955ccbc1ac214b208
5
5
  SHA512:
6
- metadata.gz: 341611451bd572895934709477ec7e974a47d7f5dd6decdb00a70b9ce724ed70b2a7ca0552f0be9e4a6afad91d94faff38c608f960ceb009587bd8a75c524e4e
7
- data.tar.gz: 5870888b34b6caf62018c6ef69c7703c074126c6cf339ba49173cfe31b64eda2d930cf3bcd0da7906ec660949bfc091e8d0b924fcfe89ed4679af0268d5f18ea
6
+ metadata.gz: a2c03ccf133b8c340f54c64e0453261ee22e2fc59f54c1b4dc2094060ff450052d084e3a65128772c5887873d57d574d495dee74dcfe70bf40d79ee820200552
7
+ data.tar.gz: ae37e2cbdf0def65d1188ee3269e06bc6b8396536abdec6f122ce2f30725b2b48de6ec80a020d279d893e5cede4e2a90f4484a10c7666602099e6266a23d8d93
data/.gitignore CHANGED
@@ -3,9 +3,9 @@
3
3
  /Gemfile.lock
4
4
  /_yardoc/
5
5
  /coverage/
6
- /doc/
7
6
  /pkg/
8
7
  /spec/reports/
8
+ /gemfiles/*.lock
9
9
  /tmp/
10
10
  .byebug_history
11
11
  spec/dummy/log/*
data/.travis.yml CHANGED
@@ -1,9 +1,17 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.0
5
- before_install: gem install bundler -v 1.12.5
6
- script: "bundle exec appraisal rspec"
4
+ - 2.3.3
5
+
6
+ script: "bundle exec rake"
7
+
8
+ before_install:
9
+ - gem update --system
10
+ - rvm @global do gem uninstall bundler -a -x
11
+ - rvm @global do gem install bundler -v 1.14.6
12
+
13
+ install: bundle install --retry=3 --jobs=3
14
+
7
15
  gemfile:
8
16
  - gemfiles/rails_4.gemfile
9
17
  - gemfiles/rails_5.gemfile
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --plugin classmethods
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/jsonapi-suite/jsonapi_compliable.svg?branch=master)](https://travis-ci.org/jsonapi-suite/jsonapi_compliable)
4
4
 
5
- [official documentation](https://jsonapi-suite.github.io/jsonapi_suite)
5
+ [JSONAPI Suite Website](https://jsonapi-suite.github.io/jsonapi_suite)
6
+
7
+ [Documentation](https://jsonapi-suite.github.io/jsonapi_compliable)
6
8
 
7
9
  Supported Rails versions: >= 4.1
8
10
 
@@ -20,3 +22,10 @@ Or run tests for all versions:
20
22
  ```bash
21
23
  $ bin/appraisal bin/rspec
22
24
  ```
25
+
26
+ ### Generating the Documentation
27
+
28
+ ```bash
29
+ $ yard doc
30
+ $ yard server
31
+ ```
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "appraisal"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
@@ -0,0 +1,202 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: JsonapiCompliable
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "JsonapiCompliable";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index (J)</a> &raquo;
40
+
41
+
42
+ <span class="title">JsonapiCompliable</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: JsonapiCompliable
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/jsonapi_compliable.rb<span class="defines">,<br />
82
+ lib/jsonapi_compliable/base.rb,<br /> lib/jsonapi_compliable/query.rb,<br /> lib/jsonapi_compliable/rails.rb,<br /> lib/jsonapi_compliable/scope.rb,<br /> lib/jsonapi_compliable/errors.rb,<br /> lib/jsonapi_compliable/version.rb,<br /> lib/jsonapi_compliable/resource.rb,<br /> lib/jsonapi_compliable/sideload.rb,<br /> lib/jsonapi_compliable/stats/dsl.rb,<br /> lib/jsonapi_compliable/util/hash.rb,<br /> lib/jsonapi_compliable/scoping/base.rb,<br /> lib/jsonapi_compliable/scoping/sort.rb,<br /> lib/jsonapi_compliable/adapters/null.rb,<br /> lib/jsonapi_compliable/stats/payload.rb,<br /> lib/jsonapi_compliable/scoping/filter.rb,<br /> lib/jsonapi_compliable/scoping/paginate.rb,<br /> lib/jsonapi_compliable/adapters/abstract.rb,<br /> lib/jsonapi_compliable/util/field_params.rb,<br /> lib/jsonapi_compliable/extensions/temp_id.rb,<br /> lib/jsonapi_compliable/scoping/filterable.rb,<br /> lib/jsonapi_compliable/util/include_params.rb,<br /> lib/jsonapi_compliable/util/render_options.rb,<br /> lib/jsonapi_compliable/scoping/extra_fields.rb,<br /> lib/jsonapi_compliable/adapters/active_record.rb,<br /> lib/jsonapi_compliable/scoping/default_filter.rb,<br /> lib/jsonapi_compliable/util/relationship_payload.rb,<br /> lib/jsonapi_compliable/extensions/extra_attribute.rb,<br /> lib/jsonapi_compliable/extensions/boolean_attribute.rb,<br /> lib/jsonapi_compliable/adapters/active_record_sideloading.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Defined Under Namespace</h2>
89
+ <p class="children">
90
+
91
+
92
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="JsonapiCompliable/Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span>, <span class='object_link'><a href="JsonapiCompliable/Base.html" title="JsonapiCompliable::Base (module)">Base</a></span>, <span class='object_link'><a href="JsonapiCompliable/Errors.html" title="JsonapiCompliable::Errors (module)">Errors</a></span>, <span class='object_link'><a href="JsonapiCompliable/Extensions.html" title="JsonapiCompliable::Extensions (module)">Extensions</a></span>, <span class='object_link'><a href="JsonapiCompliable/Rails.html" title="JsonapiCompliable::Rails (module)">Rails</a></span>, <span class='object_link'><a href="JsonapiCompliable/Scoping.html" title="JsonapiCompliable::Scoping (module)">Scoping</a></span>, <span class='object_link'><a href="JsonapiCompliable/SerializableTempId.html" title="JsonapiCompliable::SerializableTempId (module)">SerializableTempId</a></span>, <span class='object_link'><a href="JsonapiCompliable/Stats.html" title="JsonapiCompliable::Stats (module)">Stats</a></span>, <span class='object_link'><a href="JsonapiCompliable/Util.html" title="JsonapiCompliable::Util (module)">Util</a></span>
93
+
94
+
95
+
96
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="JsonapiCompliable/Deserializer.html" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span>, <span class='object_link'><a href="JsonapiCompliable/Query.html" title="JsonapiCompliable::Query (class)">Query</a></span>, <span class='object_link'><a href="JsonapiCompliable/Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span>, <span class='object_link'><a href="JsonapiCompliable/Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span>, <span class='object_link'><a href="JsonapiCompliable/Sideload.html" title="JsonapiCompliable::Sideload (class)">Sideload</a></span>
97
+
98
+
99
+ </p>
100
+
101
+ <h2>Constant Summary</h2>
102
+ <dl class="constants">
103
+
104
+ <dt id="VERSION-constant" class="">VERSION =
105
+
106
+ </dt>
107
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.6.4</span><span class='tstring_end'>&quot;</span></span></pre></dd>
108
+
109
+ </dl>
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+ <h2>
119
+ Class Method Summary
120
+ <small><a href="#" class="summary_toggle">collapse</a></small>
121
+ </h2>
122
+
123
+ <ul class="summary">
124
+
125
+ <li class="public ">
126
+ <span class="summary_signature">
127
+
128
+ <a href="#included-class_method" title="included (class method)">.<strong>included</strong>(klass) &#x21d2; Object </a>
129
+
130
+
131
+
132
+ </span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'></div></span>
143
+
144
+ </li>
145
+
146
+
147
+ </ul>
148
+
149
+
150
+
151
+
152
+ <div id="class_method_details" class="method_details_list">
153
+ <h2>Class Method Details</h2>
154
+
155
+
156
+ <div class="method_details first">
157
+ <h3 class="signature first" id="included-class_method">
158
+
159
+ .<strong>included</strong>(klass) &#x21d2; <tt>Object</tt>
160
+
161
+
162
+
163
+
164
+
165
+ </h3><table class="source_code">
166
+ <tr>
167
+ <td>
168
+ <pre class="lines">
169
+
170
+
171
+ 40
172
+ 41
173
+ 42
174
+ 43
175
+ 44</pre>
176
+ </td>
177
+ <td>
178
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable.rb', line 40</span>
179
+
180
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
181
+ <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_instance_eval'>instance_eval</span> <span class='kw'>do</span>
182
+ <span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="JsonapiCompliable/Base.html" title="JsonapiCompliable::Base (module)">Base</a></span></span>
183
+ <span class='kw'>end</span>
184
+ <span class='kw'>end</span></pre>
185
+ </td>
186
+ </tr>
187
+ </table>
188
+ </div>
189
+
190
+ </div>
191
+
192
+ </div>
193
+
194
+ <div id="footer">
195
+ Generated on Fri May 5 15:53:21 2017 by
196
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
197
+ 0.9.9 (ruby-2.3.0).
198
+ </div>
199
+
200
+ </div>
201
+ </body>
202
+ </html>
@@ -0,0 +1,119 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: JsonapiCompliable::Adapters
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "JsonapiCompliable::Adapters";
19
+ relpath = '../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../_index.html">Index (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span>
41
+ &raquo;
42
+ <span class="title">Adapters</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: JsonapiCompliable::Adapters
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/jsonapi_compliable/adapters/null.rb<span class="defines">,<br />
82
+ lib/jsonapi_compliable/adapters/abstract.rb,<br /> lib/jsonapi_compliable/adapters/active_record.rb,<br /> lib/jsonapi_compliable/adapters/active_record_sideloading.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Defined Under Namespace</h2>
89
+ <p class="children">
90
+
91
+
92
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Adapters/ActiveRecordSideloading.html" title="JsonapiCompliable::Adapters::ActiveRecordSideloading (module)">ActiveRecordSideloading</a></span>
93
+
94
+
95
+
96
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Adapters/Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Abstract</a></span>, <span class='object_link'><a href="Adapters/ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span>, <span class='object_link'><a href="Adapters/Null.html" title="JsonapiCompliable::Adapters::Null (class)">Null</a></span>
97
+
98
+
99
+ </p>
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ </div>
110
+
111
+ <div id="footer">
112
+ Generated on Fri May 5 15:53:21 2017 by
113
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
114
+ 0.9.9 (ruby-2.3.0).
115
+ </div>
116
+
117
+ </div>
118
+ </body>
119
+ </html>
@@ -0,0 +1,2285 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Class: JsonapiCompliable::Adapters::Abstract
8
+
9
+ &mdash; Documentation by YARD 0.9.9
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "JsonapiCompliable::Adapters::Abstract";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span>
41
+ &raquo;
42
+ <span class="title">Abstract</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Class: JsonapiCompliable::Adapters::Abstract
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">JsonapiCompliable::Adapters::Abstract</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/jsonapi_compliable/adapters/abstract.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Adapters DRY up common resource logic.</p>
106
+
107
+ <p>For instance, there&#39;s no reason to write ActiveRecord logic like this
108
+ in every Resource:</p>
109
+
110
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_allow_filter'>allow_filter</span> <span class='symbol'>:title</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
111
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>title:</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
112
+ <span class='kw'>end</span>
113
+
114
+ <span class='id identifier rubyid_sort'>sort</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_att'>att</span><span class='comma'>,</span> <span class='id identifier rubyid_dir'>dir</span><span class='op'>|</span>
115
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_att'>att</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_dir'>dir</span><span class='rparen'>)</span>
116
+ <span class='kw'>end</span>
117
+
118
+ <span class='id identifier rubyid_paginate'>paginate</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='op'>|</span>
119
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='lparen'>(</span><span class='id identifier rubyid_current_page'>current_page</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_per'>per</span><span class='lparen'>(</span><span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
120
+ <span class='kw'>end</span>
121
+ </code></pre>
122
+
123
+ <p>This logic can be re-used through an <strong>Adapter</strong>:</p>
124
+
125
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_use_adapter'>use_adapter</span> <span class='const'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span></span>
126
+ <span class='id identifier rubyid_allow_filter'>allow_filter</span> <span class='symbol'>:title</span>
127
+ </code></pre>
128
+
129
+ <p>Adapters are pretty simple to write. The corresponding code for the above
130
+ ActiveRecord adapter, which should look pretty familiar:</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span></span>
133
+ <span class='kw'>def</span> <span class='id identifier rubyid_filter'>filter</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
134
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
135
+ <span class='kw'>end</span>
136
+
137
+ <span class='kw'>def</span> <span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
138
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
139
+ <span class='kw'>end</span>
140
+
141
+ <span class='kw'>def</span> <span class='id identifier rubyid_paginate'>paginate</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
142
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='lparen'>(</span><span class='id identifier rubyid_current_page'>current_page</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_per'>per</span><span class='lparen'>(</span><span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
143
+ <span class='kw'>end</span>
144
+ <span class='kw'>end</span>
145
+ </code></pre>
146
+
147
+ <p>An adapter can have a corresponding <code>sideloading_module</code>. This
148
+ module gets mixed in to a Sideload. In other words,
149
+ <strong>Resource</strong> is to <strong>Adapter</strong> as
150
+ <strong>Sideload</strong> is to *Adapter#sideloading_module*. Use this
151
+ module to define DSL methods that wrap #allow_sideload:</p>
152
+
153
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>MyAdapter</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span><span class='op'>::</span><span class='const'>Abstract</span>
154
+ <span class='comment'># ... code ...
155
+ </span> <span class='kw'>def</span> <span class='id identifier rubyid_sideloading_module'>sideloading_module</span>
156
+ <span class='const'>MySideloadingAdapter</span>
157
+ <span class='kw'>end</span>
158
+ <span class='kw'>end</span>
159
+
160
+ <span class='kw'>module</span> <span class='const'>MySideloadingAdapter</span>
161
+ <span class='kw'>def</span> <span class='id identifier rubyid_belongs_to'>belongs_to</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span>
162
+ <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span> <span class='kw'>do</span>
163
+ <span class='comment'># ... code ...
164
+ </span> <span class='kw'>end</span>
165
+ <span class='kw'>end</span>
166
+ <span class='kw'>end</span>
167
+
168
+ <span class='comment'># And now in your Resource:
169
+ </span><span class='kw'>class</span> <span class='const'>MyResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
170
+ <span class='comment'># ... code ...
171
+ </span> <span class='id identifier rubyid_use_adapter'>use_adapter</span> <span class='const'>MyAdapter</span>
172
+
173
+ <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:my_association</span>
174
+ <span class='kw'>end</span>
175
+ </code></pre>
176
+
177
+ <p>If you need the adapter to do <strong>nothing</strong>, because perhaps the
178
+ API you are hitting does not support sorting, use
179
+ <code>JsonapiCompliable::Adapters::Null</code>.</p>
180
+
181
+
182
+ </div>
183
+ </div>
184
+ <div class="tags">
185
+
186
+
187
+ <p class="tag_title">See Also:</p>
188
+ <ul class="see">
189
+
190
+ <li><span class='object_link'><a href="../Resource.html#use_adapter-class_method" title="JsonapiCompliable::Resource.use_adapter (method)">Resource.use_adapter</a></span></li>
191
+
192
+ <li><span class='object_link'><a href="ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span></li>
193
+
194
+ <li><span class='object_link'><a href="ActiveRecordSideloading.html" title="JsonapiCompliable::Adapters::ActiveRecordSideloading (module)">ActiveRecordSideloading</a></span></li>
195
+
196
+ <li><span class='object_link'><a href="Null.html" title="JsonapiCompliable::Adapters::Null (class)">Null</a></span></li>
197
+
198
+ </ul>
199
+
200
+ </div><div id="subclasses">
201
+ <h2>Direct Known Subclasses</h2>
202
+ <p class="children"><span class='object_link'><a href="ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span>, <span class='object_link'><a href="Null.html" title="JsonapiCompliable::Adapters::Null (class)">Null</a></span></p>
203
+ </div>
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+ <h2>
213
+ Instance Method Summary
214
+ <small><a href="#" class="summary_toggle">collapse</a></small>
215
+ </h2>
216
+
217
+ <ul class="summary">
218
+
219
+ <li class="public ">
220
+ <span class="summary_signature">
221
+
222
+ <a href="#associate-instance_method" title="#associate (instance method)">#<strong>associate</strong>(parent, child, association_name, association_type) &#x21d2; Object </a>
223
+
224
+
225
+
226
+ </span>
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ <span class="summary_desc"><div class='inline'>
237
+ <p>Assign these two objects together.</p>
238
+ </div></span>
239
+
240
+ </li>
241
+
242
+
243
+ <li class="public ">
244
+ <span class="summary_signature">
245
+
246
+ <a href="#average-instance_method" title="#average (instance method)">#<strong>average</strong>(scope, attr) &#x21d2; Float </a>
247
+
248
+
249
+
250
+ </span>
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+ <span class="summary_desc"><div class='inline'>
261
+ <p>The average of the scope.</p>
262
+ </div></span>
263
+
264
+ </li>
265
+
266
+
267
+ <li class="public ">
268
+ <span class="summary_signature">
269
+
270
+ <a href="#count-instance_method" title="#count (instance method)">#<strong>count</strong>(scope, attr) &#x21d2; Numeric </a>
271
+
272
+
273
+
274
+ </span>
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+ <span class="summary_desc"><div class='inline'>
285
+ <p>The count of the scope.</p>
286
+ </div></span>
287
+
288
+ </li>
289
+
290
+
291
+ <li class="public ">
292
+ <span class="summary_signature">
293
+
294
+ <a href="#create-instance_method" title="#create (instance method)">#<strong>create</strong>(model_class, create_params) &#x21d2; Object </a>
295
+
296
+
297
+
298
+ </span>
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+ <span class="summary_desc"><div class='inline'>
309
+ <p>The model instance just created.</p>
310
+ </div></span>
311
+
312
+ </li>
313
+
314
+
315
+ <li class="public ">
316
+ <span class="summary_signature">
317
+
318
+ <a href="#destroy-instance_method" title="#destroy (instance method)">#<strong>destroy</strong>(model_class, id) &#x21d2; Object </a>
319
+
320
+
321
+
322
+ </span>
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+ <span class="summary_desc"><div class='inline'>
333
+ <p>The model instance just destroyed.</p>
334
+ </div></span>
335
+
336
+ </li>
337
+
338
+
339
+ <li class="public ">
340
+ <span class="summary_signature">
341
+
342
+ <a href="#filter-instance_method" title="#filter (instance method)">#<strong>filter</strong>(scope, attribute, value) &#x21d2; Object </a>
343
+
344
+
345
+
346
+ </span>
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+ <span class="summary_desc"><div class='inline'>
357
+ <p>The scope.</p>
358
+ </div></span>
359
+
360
+ </li>
361
+
362
+
363
+ <li class="public ">
364
+ <span class="summary_signature">
365
+
366
+ <a href="#maximum-instance_method" title="#maximum (instance method)">#<strong>maximum</strong>(scope, attr) &#x21d2; Numeric </a>
367
+
368
+
369
+
370
+ </span>
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+ <span class="summary_desc"><div class='inline'>
381
+ <p>The maximum value of the scope.</p>
382
+ </div></span>
383
+
384
+ </li>
385
+
386
+
387
+ <li class="public ">
388
+ <span class="summary_signature">
389
+
390
+ <a href="#minimum-instance_method" title="#minimum (instance method)">#<strong>minimum</strong>(scope, attr) &#x21d2; Numeric </a>
391
+
392
+
393
+
394
+ </span>
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+ <span class="summary_desc"><div class='inline'>
405
+ <p>The maximum value of the scope.</p>
406
+ </div></span>
407
+
408
+ </li>
409
+
410
+
411
+ <li class="public ">
412
+ <span class="summary_signature">
413
+
414
+ <a href="#order-instance_method" title="#order (instance method)">#<strong>order</strong>(scope, attribute, direction) &#x21d2; Object </a>
415
+
416
+
417
+
418
+ </span>
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+ <span class="summary_desc"><div class='inline'>
429
+ <p>The scope.</p>
430
+ </div></span>
431
+
432
+ </li>
433
+
434
+
435
+ <li class="public ">
436
+ <span class="summary_signature">
437
+
438
+ <a href="#paginate-instance_method" title="#paginate (instance method)">#<strong>paginate</strong>(scope, current_page, per_page) &#x21d2; Object </a>
439
+
440
+
441
+
442
+ </span>
443
+
444
+
445
+
446
+
447
+
448
+
449
+
450
+
451
+
452
+ <span class="summary_desc"><div class='inline'>
453
+ <p>The scope.</p>
454
+ </div></span>
455
+
456
+ </li>
457
+
458
+
459
+ <li class="public ">
460
+ <span class="summary_signature">
461
+
462
+ <a href="#resolve-instance_method" title="#resolve (instance method)">#<strong>resolve</strong>(scope) &#x21d2; Object </a>
463
+
464
+
465
+
466
+ </span>
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+
476
+ <span class="summary_desc"><div class='inline'>
477
+ <p>Resolve the scope.</p>
478
+ </div></span>
479
+
480
+ </li>
481
+
482
+
483
+ <li class="public ">
484
+ <span class="summary_signature">
485
+
486
+ <a href="#sideloading_module-instance_method" title="#sideloading_module (instance method)">#<strong>sideloading_module</strong> &#x21d2; Object </a>
487
+
488
+
489
+
490
+ </span>
491
+
492
+
493
+
494
+
495
+
496
+
497
+
498
+
499
+
500
+ <span class="summary_desc"><div class='inline'>
501
+ <p>This module gets mixed in to Sideload classes This is where you define
502
+ methods like has_many, belongs_to etc that wrap the lower-level
503
+ Sideload#allow_sideload.</p>
504
+ </div></span>
505
+
506
+ </li>
507
+
508
+
509
+ <li class="public ">
510
+ <span class="summary_signature">
511
+
512
+ <a href="#sum-instance_method" title="#sum (instance method)">#<strong>sum</strong>(scope, attr) &#x21d2; Numeric </a>
513
+
514
+
515
+
516
+ </span>
517
+
518
+
519
+
520
+
521
+
522
+
523
+
524
+
525
+
526
+ <span class="summary_desc"><div class='inline'>
527
+ <p>The sum of the scope.</p>
528
+ </div></span>
529
+
530
+ </li>
531
+
532
+
533
+ <li class="public ">
534
+ <span class="summary_signature">
535
+
536
+ <a href="#transaction-instance_method" title="#transaction (instance method)">#<strong>transaction</strong>(model_class) &#x21d2; Object </a>
537
+
538
+
539
+
540
+ </span>
541
+
542
+
543
+
544
+
545
+
546
+
547
+
548
+
549
+
550
+ <span class="summary_desc"><div class='inline'>
551
+ <p>This method must <code>yield</code> the code to run within the transaction.</p>
552
+ </div></span>
553
+
554
+ </li>
555
+
556
+
557
+ <li class="public ">
558
+ <span class="summary_signature">
559
+
560
+ <a href="#update-instance_method" title="#update (instance method)">#<strong>update</strong>(model_class, update_params) &#x21d2; Object </a>
561
+
562
+
563
+
564
+ </span>
565
+
566
+
567
+
568
+
569
+
570
+
571
+
572
+
573
+
574
+ <span class="summary_desc"><div class='inline'>
575
+ <p>The model instance just created.</p>
576
+ </div></span>
577
+
578
+ </li>
579
+
580
+
581
+ </ul>
582
+
583
+
584
+
585
+
586
+ <div id="instance_method_details" class="method_details_list">
587
+ <h2>Instance Method Details</h2>
588
+
589
+
590
+ <div class="method_details first">
591
+ <h3 class="signature first" id="associate-instance_method">
592
+
593
+ #<strong>associate</strong>(parent, child, association_name, association_type) &#x21d2; <tt>Object</tt>
594
+
595
+
596
+
597
+
598
+
599
+ </h3><div class="docstring">
600
+ <div class="discussion">
601
+
602
+ <p>Assign these two objects together.</p>
603
+
604
+ <p><code>association_name</code> and <code>association_type</code> come from
605
+ your sideload configuration:</p>
606
+
607
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:the_name</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='id identifier rubyid_the_type'>the_type</span> <span class='kw'>do</span>
608
+ <span class='comment'># ... code.
609
+ </span><span class='kw'>end</span>
610
+ </code></pre>
611
+
612
+
613
+ </div>
614
+ </div>
615
+ <div class="tags">
616
+
617
+ <div class="examples">
618
+ <p class="tag_title">Examples:</p>
619
+
620
+
621
+ <p class="example_title"><div class='inline'>
622
+ <p>Basic accessor</p>
623
+ </div></p>
624
+
625
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_associate'>associate</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='id identifier rubyid_association_type'>association_type</span><span class='rparen'>)</span>
626
+ <span class='kw'>if</span> <span class='id identifier rubyid_association_type'>association_type</span> <span class='op'>==</span> <span class='symbol'>:has_many</span>
627
+ <span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_child'>child</span><span class='rparen'>)</span>
628
+ <span class='kw'>else</span>
629
+ <span class='id identifier rubyid_child'>child</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:#{</span><span class='id identifier rubyid_association_name'>association_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span><span class='rparen'>)</span>
630
+ <span class='kw'>end</span>
631
+ <span class='kw'>end</span></code></pre>
632
+
633
+ </div>
634
+ <p class="tag_title">Parameters:</p>
635
+ <ul class="param">
636
+
637
+ <li>
638
+
639
+ <span class='name'>parent</span>
640
+
641
+
642
+ <span class='type'></span>
643
+
644
+
645
+
646
+ &mdash;
647
+ <div class='inline'>
648
+ <p>The parent object (via the JSONAPI &#39;relationships&#39; graph)</p>
649
+ </div>
650
+
651
+ </li>
652
+
653
+ <li>
654
+
655
+ <span class='name'>child</span>
656
+
657
+
658
+ <span class='type'></span>
659
+
660
+
661
+
662
+ &mdash;
663
+ <div class='inline'>
664
+ <p>The child object (via the JSONAPI &#39;relationships&#39; graph)</p>
665
+ </div>
666
+
667
+ </li>
668
+
669
+ <li>
670
+
671
+ <span class='name'>association_name</span>
672
+
673
+
674
+ <span class='type'></span>
675
+
676
+
677
+
678
+ &mdash;
679
+ <div class='inline'>
680
+ <p>The &#39;relationships&#39; key we are processing</p>
681
+ </div>
682
+
683
+ </li>
684
+
685
+ <li>
686
+
687
+ <span class='name'>association_type</span>
688
+
689
+
690
+ <span class='type'></span>
691
+
692
+
693
+
694
+ &mdash;
695
+ <div class='inline'>
696
+ <p>The Sideload type (see Sideload#type). Usually :has_many/:belongs_to/etc</p>
697
+ </div>
698
+
699
+ </li>
700
+
701
+ </ul>
702
+
703
+
704
+ </div><table class="source_code">
705
+ <tr>
706
+ <td>
707
+ <pre class="lines">
708
+
709
+
710
+ 236
711
+ 237
712
+ 238</pre>
713
+ </td>
714
+ <td>
715
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 236</span>
716
+
717
+ <span class='kw'>def</span> <span class='id identifier rubyid_associate'>associate</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='id identifier rubyid_association_type'>association_type</span><span class='rparen'>)</span>
718
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #associate in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
719
+ <span class='kw'>end</span></pre>
720
+ </td>
721
+ </tr>
722
+ </table>
723
+ </div>
724
+
725
+ <div class="method_details ">
726
+ <h3 class="signature " id="average-instance_method">
727
+
728
+ #<strong>average</strong>(scope, attr) &#x21d2; <tt>Float</tt>
729
+
730
+
731
+
732
+
733
+
734
+ </h3><div class="docstring">
735
+ <div class="discussion">
736
+
737
+ <p>Returns the average of the scope</p>
738
+
739
+
740
+ </div>
741
+ </div>
742
+ <div class="tags">
743
+
744
+ <div class="examples">
745
+ <p class="tag_title">Examples:</p>
746
+
747
+
748
+ <p class="example_title"><div class='inline'>
749
+ <p>ActiveRecord default</p>
750
+ </div></p>
751
+
752
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
753
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span>
754
+ <span class='kw'>end</span></code></pre>
755
+
756
+ </div>
757
+ <p class="tag_title">Parameters:</p>
758
+ <ul class="param">
759
+
760
+ <li>
761
+
762
+ <span class='name'>scope</span>
763
+
764
+
765
+ <span class='type'></span>
766
+
767
+
768
+
769
+ &mdash;
770
+ <div class='inline'>
771
+ <p>the scope object we are chaining</p>
772
+ </div>
773
+
774
+ </li>
775
+
776
+ <li>
777
+
778
+ <span class='name'>attr</span>
779
+
780
+
781
+ <span class='type'>(<tt>Symbol</tt>)</span>
782
+
783
+
784
+
785
+ &mdash;
786
+ <div class='inline'>
787
+ <p>corresponding stat attribute name</p>
788
+ </div>
789
+
790
+ </li>
791
+
792
+ </ul>
793
+
794
+ <p class="tag_title">Returns:</p>
795
+ <ul class="return">
796
+
797
+ <li>
798
+
799
+
800
+ <span class='type'>(<tt>Float</tt>)</span>
801
+
802
+
803
+
804
+ &mdash;
805
+ <div class='inline'>
806
+ <p>the average of the scope</p>
807
+ </div>
808
+
809
+ </li>
810
+
811
+ </ul>
812
+
813
+ </div><table class="source_code">
814
+ <tr>
815
+ <td>
816
+ <pre class="lines">
817
+
818
+
819
+ 138
820
+ 139
821
+ 140</pre>
822
+ </td>
823
+ <td>
824
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 138</span>
825
+
826
+ <span class='kw'>def</span> <span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
827
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #average in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
828
+ <span class='kw'>end</span></pre>
829
+ </td>
830
+ </tr>
831
+ </table>
832
+ </div>
833
+
834
+ <div class="method_details ">
835
+ <h3 class="signature " id="count-instance_method">
836
+
837
+ #<strong>count</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
838
+
839
+
840
+
841
+
842
+
843
+ </h3><div class="docstring">
844
+ <div class="discussion">
845
+
846
+ <p>Returns the count of the scope</p>
847
+
848
+
849
+ </div>
850
+ </div>
851
+ <div class="tags">
852
+
853
+ <div class="examples">
854
+ <p class="tag_title">Examples:</p>
855
+
856
+
857
+ <p class="example_title"><div class='inline'>
858
+ <p>ActiveRecord default</p>
859
+ </div></p>
860
+
861
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
862
+ <span class='id identifier rubyid_column'>column</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>==</span> <span class='symbol'>:total</span> <span class='op'>?</span> <span class='symbol'>:all</span> <span class='op'>:</span> <span class='id identifier rubyid_attr'>attr</span>
863
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_column'>column</span><span class='rparen'>)</span>
864
+ <span class='kw'>end</span></code></pre>
865
+
866
+ </div>
867
+ <p class="tag_title">Parameters:</p>
868
+ <ul class="param">
869
+
870
+ <li>
871
+
872
+ <span class='name'>scope</span>
873
+
874
+
875
+ <span class='type'></span>
876
+
877
+
878
+
879
+ &mdash;
880
+ <div class='inline'>
881
+ <p>the scope object we are chaining</p>
882
+ </div>
883
+
884
+ </li>
885
+
886
+ <li>
887
+
888
+ <span class='name'>attr</span>
889
+
890
+
891
+ <span class='type'>(<tt>Symbol</tt>)</span>
892
+
893
+
894
+
895
+ &mdash;
896
+ <div class='inline'>
897
+ <p>corresponding stat attribute name</p>
898
+ </div>
899
+
900
+ </li>
901
+
902
+ </ul>
903
+
904
+ <p class="tag_title">Returns:</p>
905
+ <ul class="return">
906
+
907
+ <li>
908
+
909
+
910
+ <span class='type'>(<tt>Numeric</tt>)</span>
911
+
912
+
913
+
914
+ &mdash;
915
+ <div class='inline'>
916
+ <p>the count of the scope</p>
917
+ </div>
918
+
919
+ </li>
920
+
921
+ </ul>
922
+
923
+ </div><table class="source_code">
924
+ <tr>
925
+ <td>
926
+ <pre class="lines">
927
+
928
+
929
+ 127
930
+ 128
931
+ 129</pre>
932
+ </td>
933
+ <td>
934
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 127</span>
935
+
936
+ <span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
937
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #count in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
938
+ <span class='kw'>end</span></pre>
939
+ </td>
940
+ </tr>
941
+ </table>
942
+ </div>
943
+
944
+ <div class="method_details ">
945
+ <h3 class="signature " id="create-instance_method">
946
+
947
+ #<strong>create</strong>(model_class, create_params) &#x21d2; <tt>Object</tt>
948
+
949
+
950
+
951
+
952
+
953
+ </h3><div class="docstring">
954
+ <div class="discussion">
955
+
956
+ <p>Returns the model instance just created</p>
957
+
958
+
959
+ </div>
960
+ </div>
961
+ <div class="tags">
962
+
963
+ <div class="examples">
964
+ <p class="tag_title">Examples:</p>
965
+
966
+
967
+ <p class="example_title"><div class='inline'>
968
+ <p>ActiveRecord default</p>
969
+ </div></p>
970
+
971
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
972
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
973
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
974
+ <span class='id identifier rubyid_instance'>instance</span>
975
+ <span class='kw'>end</span></code></pre>
976
+
977
+ </div>
978
+ <p class="tag_title">Parameters:</p>
979
+ <ul class="param">
980
+
981
+ <li>
982
+
983
+ <span class='name'>model_class</span>
984
+
985
+
986
+ <span class='type'>(<tt>Class</tt>)</span>
987
+
988
+
989
+
990
+ &mdash;
991
+ <div class='inline'>
992
+ <p>The configured model class (see Resource.model)</p>
993
+ </div>
994
+
995
+ </li>
996
+
997
+ <li>
998
+
999
+ <span class='name'>create_params</span>
1000
+
1001
+
1002
+ <span class='type'>(<tt>Hash</tt>)</span>
1003
+
1004
+
1005
+
1006
+ &mdash;
1007
+ <div class='inline'>
1008
+ <p>Attributes + id</p>
1009
+ </div>
1010
+
1011
+ </li>
1012
+
1013
+ </ul>
1014
+
1015
+ <p class="tag_title">Returns:</p>
1016
+ <ul class="return">
1017
+
1018
+ <li>
1019
+
1020
+
1021
+ <span class='type'></span>
1022
+
1023
+
1024
+
1025
+
1026
+ <div class='inline'>
1027
+ <p>the model instance just created</p>
1028
+ </div>
1029
+
1030
+ </li>
1031
+
1032
+ </ul>
1033
+
1034
+ <p class="tag_title">See Also:</p>
1035
+ <ul class="see">
1036
+
1037
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
1038
+
1039
+ </ul>
1040
+
1041
+ </div><table class="source_code">
1042
+ <tr>
1043
+ <td>
1044
+ <pre class="lines">
1045
+
1046
+
1047
+ 263
1048
+ 264
1049
+ 265</pre>
1050
+ </td>
1051
+ <td>
1052
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 263</span>
1053
+
1054
+ <span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
1055
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #create in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1056
+ <span class='kw'>end</span></pre>
1057
+ </td>
1058
+ </tr>
1059
+ </table>
1060
+ </div>
1061
+
1062
+ <div class="method_details ">
1063
+ <h3 class="signature " id="destroy-instance_method">
1064
+
1065
+ #<strong>destroy</strong>(model_class, id) &#x21d2; <tt>Object</tt>
1066
+
1067
+
1068
+
1069
+
1070
+
1071
+ </h3><div class="docstring">
1072
+ <div class="discussion">
1073
+
1074
+ <p>Returns the model instance just destroyed</p>
1075
+
1076
+
1077
+ </div>
1078
+ </div>
1079
+ <div class="tags">
1080
+
1081
+ <div class="examples">
1082
+ <p class="tag_title">Examples:</p>
1083
+
1084
+
1085
+ <p class="example_title"><div class='inline'>
1086
+ <p>ActiveRecord default</p>
1087
+ </div></p>
1088
+
1089
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_destroy'>destroy</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1090
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1091
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_destroy'>destroy</span>
1092
+ <span class='id identifier rubyid_instance'>instance</span>
1093
+ <span class='kw'>end</span></code></pre>
1094
+
1095
+ </div>
1096
+ <p class="tag_title">Parameters:</p>
1097
+ <ul class="param">
1098
+
1099
+ <li>
1100
+
1101
+ <span class='name'>model_class</span>
1102
+
1103
+
1104
+ <span class='type'>(<tt>Class</tt>)</span>
1105
+
1106
+
1107
+
1108
+ &mdash;
1109
+ <div class='inline'>
1110
+ <p>The configured model class (see Resource.model)</p>
1111
+ </div>
1112
+
1113
+ </li>
1114
+
1115
+ <li>
1116
+
1117
+ <span class='name'>id</span>
1118
+
1119
+
1120
+ <span class='type'>(<tt>Integer</tt>)</span>
1121
+
1122
+
1123
+
1124
+ &mdash;
1125
+ <div class='inline'>
1126
+ <p>the id for this model</p>
1127
+ </div>
1128
+
1129
+ </li>
1130
+
1131
+ </ul>
1132
+
1133
+ <p class="tag_title">Returns:</p>
1134
+ <ul class="return">
1135
+
1136
+ <li>
1137
+
1138
+
1139
+ <span class='type'></span>
1140
+
1141
+
1142
+
1143
+
1144
+ <div class='inline'>
1145
+ <p>the model instance just destroyed</p>
1146
+ </div>
1147
+
1148
+ </li>
1149
+
1150
+ </ul>
1151
+
1152
+ <p class="tag_title">See Also:</p>
1153
+ <ul class="see">
1154
+
1155
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
1156
+
1157
+ </ul>
1158
+
1159
+ </div><table class="source_code">
1160
+ <tr>
1161
+ <td>
1162
+ <pre class="lines">
1163
+
1164
+
1165
+ 291
1166
+ 292
1167
+ 293</pre>
1168
+ </td>
1169
+ <td>
1170
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 291</span>
1171
+
1172
+ <span class='kw'>def</span> <span class='id identifier rubyid_destroy'>destroy</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1173
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #destroy in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1174
+ <span class='kw'>end</span></pre>
1175
+ </td>
1176
+ </tr>
1177
+ </table>
1178
+ </div>
1179
+
1180
+ <div class="method_details ">
1181
+ <h3 class="signature " id="filter-instance_method">
1182
+
1183
+ #<strong>filter</strong>(scope, attribute, value) &#x21d2; <tt>Object</tt>
1184
+
1185
+
1186
+
1187
+
1188
+
1189
+ </h3><div class="docstring">
1190
+ <div class="discussion">
1191
+
1192
+ <p>Returns the scope</p>
1193
+
1194
+
1195
+ </div>
1196
+ </div>
1197
+ <div class="tags">
1198
+
1199
+ <div class="examples">
1200
+ <p class="tag_title">Examples:</p>
1201
+
1202
+
1203
+ <p class="example_title"><div class='inline'>
1204
+ <p>ActiveRecord default</p>
1205
+ </div></p>
1206
+
1207
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_filter'>filter</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1208
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1209
+ <span class='kw'>end</span></code></pre>
1210
+
1211
+ </div>
1212
+ <p class="tag_title">Parameters:</p>
1213
+ <ul class="param">
1214
+
1215
+ <li>
1216
+
1217
+ <span class='name'>scope</span>
1218
+
1219
+
1220
+ <span class='type'></span>
1221
+
1222
+
1223
+
1224
+ &mdash;
1225
+ <div class='inline'>
1226
+ <p>The scope object we are chaining</p>
1227
+ </div>
1228
+
1229
+ </li>
1230
+
1231
+ <li>
1232
+
1233
+ <span class='name'>attribute</span>
1234
+
1235
+
1236
+ <span class='type'>(<tt>Symbol</tt>)</span>
1237
+
1238
+
1239
+
1240
+ &mdash;
1241
+ <div class='inline'>
1242
+ <p>The attribute name we are filtering</p>
1243
+ </div>
1244
+
1245
+ </li>
1246
+
1247
+ <li>
1248
+
1249
+ <span class='name'>value</span>
1250
+
1251
+
1252
+ <span class='type'></span>
1253
+
1254
+
1255
+
1256
+ &mdash;
1257
+ <div class='inline'>
1258
+ <p>The corresponding query parameter value</p>
1259
+ </div>
1260
+
1261
+ </li>
1262
+
1263
+ </ul>
1264
+
1265
+ <p class="tag_title">Returns:</p>
1266
+ <ul class="return">
1267
+
1268
+ <li>
1269
+
1270
+
1271
+ <span class='type'></span>
1272
+
1273
+
1274
+
1275
+
1276
+ <div class='inline'>
1277
+ <p>the scope</p>
1278
+ </div>
1279
+
1280
+ </li>
1281
+
1282
+ </ul>
1283
+
1284
+ </div><table class="source_code">
1285
+ <tr>
1286
+ <td>
1287
+ <pre class="lines">
1288
+
1289
+
1290
+ 88
1291
+ 89
1292
+ 90</pre>
1293
+ </td>
1294
+ <td>
1295
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 88</span>
1296
+
1297
+ <span class='kw'>def</span> <span class='id identifier rubyid_filter'>filter</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1298
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #filter in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1299
+ <span class='kw'>end</span></pre>
1300
+ </td>
1301
+ </tr>
1302
+ </table>
1303
+ </div>
1304
+
1305
+ <div class="method_details ">
1306
+ <h3 class="signature " id="maximum-instance_method">
1307
+
1308
+ #<strong>maximum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1309
+
1310
+
1311
+
1312
+
1313
+
1314
+ </h3><div class="docstring">
1315
+ <div class="discussion">
1316
+
1317
+ <p>Returns the maximum value of the scope</p>
1318
+
1319
+
1320
+ </div>
1321
+ </div>
1322
+ <div class="tags">
1323
+
1324
+ <div class="examples">
1325
+ <p class="tag_title">Examples:</p>
1326
+
1327
+
1328
+ <p class="example_title"><div class='inline'>
1329
+ <p>ActiveRecord default</p>
1330
+ </div></p>
1331
+
1332
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1333
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1334
+ <span class='kw'>end</span></code></pre>
1335
+
1336
+ </div>
1337
+ <p class="tag_title">Parameters:</p>
1338
+ <ul class="param">
1339
+
1340
+ <li>
1341
+
1342
+ <span class='name'>scope</span>
1343
+
1344
+
1345
+ <span class='type'></span>
1346
+
1347
+
1348
+
1349
+ &mdash;
1350
+ <div class='inline'>
1351
+ <p>the scope object we are chaining</p>
1352
+ </div>
1353
+
1354
+ </li>
1355
+
1356
+ <li>
1357
+
1358
+ <span class='name'>attr</span>
1359
+
1360
+
1361
+ <span class='type'>(<tt>Symbol</tt>)</span>
1362
+
1363
+
1364
+
1365
+ &mdash;
1366
+ <div class='inline'>
1367
+ <p>corresponding stat attribute name</p>
1368
+ </div>
1369
+
1370
+ </li>
1371
+
1372
+ </ul>
1373
+
1374
+ <p class="tag_title">Returns:</p>
1375
+ <ul class="return">
1376
+
1377
+ <li>
1378
+
1379
+
1380
+ <span class='type'>(<tt>Numeric</tt>)</span>
1381
+
1382
+
1383
+
1384
+ &mdash;
1385
+ <div class='inline'>
1386
+ <p>the maximum value of the scope</p>
1387
+ </div>
1388
+
1389
+ </li>
1390
+
1391
+ </ul>
1392
+
1393
+ </div><table class="source_code">
1394
+ <tr>
1395
+ <td>
1396
+ <pre class="lines">
1397
+
1398
+
1399
+ 160
1400
+ 161
1401
+ 162</pre>
1402
+ </td>
1403
+ <td>
1404
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 160</span>
1405
+
1406
+ <span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1407
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #maximum in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1408
+ <span class='kw'>end</span></pre>
1409
+ </td>
1410
+ </tr>
1411
+ </table>
1412
+ </div>
1413
+
1414
+ <div class="method_details ">
1415
+ <h3 class="signature " id="minimum-instance_method">
1416
+
1417
+ #<strong>minimum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1418
+
1419
+
1420
+
1421
+
1422
+
1423
+ </h3><div class="docstring">
1424
+ <div class="discussion">
1425
+
1426
+ <p>Returns the maximum value of the scope</p>
1427
+
1428
+
1429
+ </div>
1430
+ </div>
1431
+ <div class="tags">
1432
+
1433
+ <div class="examples">
1434
+ <p class="tag_title">Examples:</p>
1435
+
1436
+
1437
+ <p class="example_title"><div class='inline'>
1438
+ <p>ActiveRecord default</p>
1439
+ </div></p>
1440
+
1441
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1442
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1443
+ <span class='kw'>end</span></code></pre>
1444
+
1445
+ </div>
1446
+ <p class="tag_title">Parameters:</p>
1447
+ <ul class="param">
1448
+
1449
+ <li>
1450
+
1451
+ <span class='name'>scope</span>
1452
+
1453
+
1454
+ <span class='type'></span>
1455
+
1456
+
1457
+
1458
+ &mdash;
1459
+ <div class='inline'>
1460
+ <p>the scope object we are chaining</p>
1461
+ </div>
1462
+
1463
+ </li>
1464
+
1465
+ <li>
1466
+
1467
+ <span class='name'>attr</span>
1468
+
1469
+
1470
+ <span class='type'>(<tt>Symbol</tt>)</span>
1471
+
1472
+
1473
+
1474
+ &mdash;
1475
+ <div class='inline'>
1476
+ <p>corresponding stat attribute name</p>
1477
+ </div>
1478
+
1479
+ </li>
1480
+
1481
+ </ul>
1482
+
1483
+ <p class="tag_title">Returns:</p>
1484
+ <ul class="return">
1485
+
1486
+ <li>
1487
+
1488
+
1489
+ <span class='type'>(<tt>Numeric</tt>)</span>
1490
+
1491
+
1492
+
1493
+ &mdash;
1494
+ <div class='inline'>
1495
+ <p>the maximum value of the scope</p>
1496
+ </div>
1497
+
1498
+ </li>
1499
+
1500
+ </ul>
1501
+
1502
+ </div><table class="source_code">
1503
+ <tr>
1504
+ <td>
1505
+ <pre class="lines">
1506
+
1507
+
1508
+ 171
1509
+ 172
1510
+ 173</pre>
1511
+ </td>
1512
+ <td>
1513
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 171</span>
1514
+
1515
+ <span class='kw'>def</span> <span class='id identifier rubyid_minimum'>minimum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1516
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #maximum in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1517
+ <span class='kw'>end</span></pre>
1518
+ </td>
1519
+ </tr>
1520
+ </table>
1521
+ </div>
1522
+
1523
+ <div class="method_details ">
1524
+ <h3 class="signature " id="order-instance_method">
1525
+
1526
+ #<strong>order</strong>(scope, attribute, direction) &#x21d2; <tt>Object</tt>
1527
+
1528
+
1529
+
1530
+
1531
+
1532
+ </h3><div class="docstring">
1533
+ <div class="discussion">
1534
+
1535
+ <p>Returns the scope</p>
1536
+
1537
+
1538
+ </div>
1539
+ </div>
1540
+ <div class="tags">
1541
+
1542
+ <div class="examples">
1543
+ <p class="tag_title">Examples:</p>
1544
+
1545
+
1546
+ <p class="example_title"><div class='inline'>
1547
+ <p>ActiveRecord default</p>
1548
+ </div></p>
1549
+
1550
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1551
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1552
+ <span class='kw'>end</span></code></pre>
1553
+
1554
+ </div>
1555
+ <p class="tag_title">Parameters:</p>
1556
+ <ul class="param">
1557
+
1558
+ <li>
1559
+
1560
+ <span class='name'>scope</span>
1561
+
1562
+
1563
+ <span class='type'></span>
1564
+
1565
+
1566
+
1567
+ &mdash;
1568
+ <div class='inline'>
1569
+ <p>The scope object we are chaining</p>
1570
+ </div>
1571
+
1572
+ </li>
1573
+
1574
+ <li>
1575
+
1576
+ <span class='name'>attribute</span>
1577
+
1578
+
1579
+ <span class='type'>(<tt>Symbol</tt>)</span>
1580
+
1581
+
1582
+
1583
+ &mdash;
1584
+ <div class='inline'>
1585
+ <p>The attribute name we are sorting</p>
1586
+ </div>
1587
+
1588
+ </li>
1589
+
1590
+ <li>
1591
+
1592
+ <span class='name'>direction</span>
1593
+
1594
+
1595
+ <span class='type'>(<tt>Symbol</tt>)</span>
1596
+
1597
+
1598
+
1599
+ &mdash;
1600
+ <div class='inline'>
1601
+ <p>The direction we are sorting (asc/desc)</p>
1602
+ </div>
1603
+
1604
+ </li>
1605
+
1606
+ </ul>
1607
+
1608
+ <p class="tag_title">Returns:</p>
1609
+ <ul class="return">
1610
+
1611
+ <li>
1612
+
1613
+
1614
+ <span class='type'></span>
1615
+
1616
+
1617
+
1618
+
1619
+ <div class='inline'>
1620
+ <p>the scope</p>
1621
+ </div>
1622
+
1623
+ </li>
1624
+
1625
+ </ul>
1626
+
1627
+ </div><table class="source_code">
1628
+ <tr>
1629
+ <td>
1630
+ <pre class="lines">
1631
+
1632
+
1633
+ 101
1634
+ 102
1635
+ 103</pre>
1636
+ </td>
1637
+ <td>
1638
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 101</span>
1639
+
1640
+ <span class='kw'>def</span> <span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1641
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #order in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1642
+ <span class='kw'>end</span></pre>
1643
+ </td>
1644
+ </tr>
1645
+ </table>
1646
+ </div>
1647
+
1648
+ <div class="method_details ">
1649
+ <h3 class="signature " id="paginate-instance_method">
1650
+
1651
+ #<strong>paginate</strong>(scope, current_page, per_page) &#x21d2; <tt>Object</tt>
1652
+
1653
+
1654
+
1655
+
1656
+
1657
+ </h3><div class="docstring">
1658
+ <div class="discussion">
1659
+
1660
+ <p>Returns the scope</p>
1661
+
1662
+
1663
+ </div>
1664
+ </div>
1665
+ <div class="tags">
1666
+
1667
+ <div class="examples">
1668
+ <p class="tag_title">Examples:</p>
1669
+
1670
+
1671
+ <p class="example_title"><div class='inline'>
1672
+ <p>ActiveRecord default</p>
1673
+ </div></p>
1674
+
1675
+ <pre class="example code"><code><span class='comment'># via kaminari gem
1676
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_paginate'>paginate</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1677
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='lparen'>(</span><span class='id identifier rubyid_current_page'>current_page</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_per'>per</span><span class='lparen'>(</span><span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1678
+ <span class='kw'>end</span></code></pre>
1679
+
1680
+ </div>
1681
+ <p class="tag_title">Parameters:</p>
1682
+ <ul class="param">
1683
+
1684
+ <li>
1685
+
1686
+ <span class='name'>scope</span>
1687
+
1688
+
1689
+ <span class='type'></span>
1690
+
1691
+
1692
+
1693
+ &mdash;
1694
+ <div class='inline'>
1695
+ <p>The scope object we are chaining</p>
1696
+ </div>
1697
+
1698
+ </li>
1699
+
1700
+ <li>
1701
+
1702
+ <span class='name'>current_page</span>
1703
+
1704
+
1705
+ <span class='type'>(<tt>Integer</tt>)</span>
1706
+
1707
+
1708
+
1709
+ &mdash;
1710
+ <div class='inline'>
1711
+ <p>The current page number</p>
1712
+ </div>
1713
+
1714
+ </li>
1715
+
1716
+ <li>
1717
+
1718
+ <span class='name'>per_page</span>
1719
+
1720
+
1721
+ <span class='type'>(<tt>Integer</tt>)</span>
1722
+
1723
+
1724
+
1725
+ &mdash;
1726
+ <div class='inline'>
1727
+ <p>The number of results per page</p>
1728
+ </div>
1729
+
1730
+ </li>
1731
+
1732
+ </ul>
1733
+
1734
+ <p class="tag_title">Returns:</p>
1735
+ <ul class="return">
1736
+
1737
+ <li>
1738
+
1739
+
1740
+ <span class='type'></span>
1741
+
1742
+
1743
+
1744
+
1745
+ <div class='inline'>
1746
+ <p>the scope</p>
1747
+ </div>
1748
+
1749
+ </li>
1750
+
1751
+ </ul>
1752
+
1753
+ </div><table class="source_code">
1754
+ <tr>
1755
+ <td>
1756
+ <pre class="lines">
1757
+
1758
+
1759
+ 115
1760
+ 116
1761
+ 117</pre>
1762
+ </td>
1763
+ <td>
1764
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 115</span>
1765
+
1766
+ <span class='kw'>def</span> <span class='id identifier rubyid_paginate'>paginate</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1767
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #paginate in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
1768
+ <span class='kw'>end</span></pre>
1769
+ </td>
1770
+ </tr>
1771
+ </table>
1772
+ </div>
1773
+
1774
+ <div class="method_details ">
1775
+ <h3 class="signature " id="resolve-instance_method">
1776
+
1777
+ #<strong>resolve</strong>(scope) &#x21d2; <tt>Object</tt>
1778
+
1779
+
1780
+
1781
+
1782
+
1783
+ </h3><div class="docstring">
1784
+ <div class="discussion">
1785
+
1786
+ <p>Resolve the scope. This is where you&#39;d actually fire SQL, actually make
1787
+ an HTTP call, etc.</p>
1788
+
1789
+
1790
+ </div>
1791
+ </div>
1792
+ <div class="tags">
1793
+
1794
+ <div class="examples">
1795
+ <p class="tag_title">Examples:</p>
1796
+
1797
+
1798
+ <p class="example_title"><div class='inline'>
1799
+ <p>ActiveRecordDefault</p>
1800
+ </div></p>
1801
+
1802
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1803
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
1804
+ <span class='kw'>end</span></code></pre>
1805
+
1806
+
1807
+ <p class="example_title"><div class='inline'>
1808
+ <p>Suggested Customization</p>
1809
+ </div></p>
1810
+
1811
+ <pre class="example code"><code><span class='comment'># When making a service call, we suggest this abstraction
1812
+ </span><span class='comment'># &#39;scope&#39; here is a hash
1813
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1814
+ <span class='comment'># The implementation of .where can be whatever you want
1815
+ </span> <span class='const'>SomeModelClass</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1816
+ <span class='kw'>end</span></code></pre>
1817
+
1818
+ </div>
1819
+ <p class="tag_title">Parameters:</p>
1820
+ <ul class="param">
1821
+
1822
+ <li>
1823
+
1824
+ <span class='name'>scope</span>
1825
+
1826
+
1827
+ <span class='type'></span>
1828
+
1829
+
1830
+
1831
+ &mdash;
1832
+ <div class='inline'>
1833
+ <p>The scope object to resolve</p>
1834
+ </div>
1835
+
1836
+ </li>
1837
+
1838
+ </ul>
1839
+
1840
+ <p class="tag_title">Returns:</p>
1841
+ <ul class="return">
1842
+
1843
+ <li>
1844
+
1845
+
1846
+ <span class='type'></span>
1847
+
1848
+
1849
+
1850
+
1851
+ <div class='inline'>
1852
+ <p>an array of Model instances</p>
1853
+ </div>
1854
+
1855
+ </li>
1856
+
1857
+ </ul>
1858
+
1859
+ <p class="tag_title">See Also:</p>
1860
+ <ul class="see">
1861
+
1862
+ <li><span class='object_link'><a href="ActiveRecord.html#resolve-instance_method" title="JsonapiCompliable::Adapters::ActiveRecord#resolve (method)">JsonapiCompliable::Adapters::ActiveRecord#resolve</a></span></li>
1863
+
1864
+ </ul>
1865
+
1866
+ </div><table class="source_code">
1867
+ <tr>
1868
+ <td>
1869
+ <pre class="lines">
1870
+
1871
+
1872
+ 210
1873
+ 211
1874
+ 212</pre>
1875
+ </td>
1876
+ <td>
1877
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 210</span>
1878
+
1879
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1880
+ <span class='id identifier rubyid_scope'>scope</span>
1881
+ <span class='kw'>end</span></pre>
1882
+ </td>
1883
+ </tr>
1884
+ </table>
1885
+ </div>
1886
+
1887
+ <div class="method_details ">
1888
+ <h3 class="signature " id="sideloading_module-instance_method">
1889
+
1890
+ #<strong>sideloading_module</strong> &#x21d2; <tt>Object</tt>
1891
+
1892
+
1893
+
1894
+
1895
+
1896
+ </h3><div class="docstring">
1897
+ <div class="discussion">
1898
+
1899
+ <p>This module gets mixed in to Sideload classes This is where you define
1900
+ methods like has_many, belongs_to etc that wrap the lower-level
1901
+ Sideload#allow_sideload</p>
1902
+
1903
+
1904
+ </div>
1905
+ </div>
1906
+ <div class="tags">
1907
+
1908
+ <p class="tag_title">Returns:</p>
1909
+ <ul class="return">
1910
+
1911
+ <li>
1912
+
1913
+
1914
+ <span class='type'></span>
1915
+
1916
+
1917
+
1918
+
1919
+ <div class='inline'>
1920
+ <p>the module to mix in</p>
1921
+ </div>
1922
+
1923
+ </li>
1924
+
1925
+ </ul>
1926
+
1927
+ <p class="tag_title">See Also:</p>
1928
+ <ul class="see">
1929
+
1930
+ <li>Resource#allow_sideload</li>
1931
+
1932
+ <li><span class='object_link'><a href="../Sideload.html#allow_sideload-instance_method" title="JsonapiCompliable::Sideload#allow_sideload (method)">Sideload#allow_sideload</a></span></li>
1933
+
1934
+ <li><span class='object_link'><a href="ActiveRecord.html#sideloading_module-instance_method" title="JsonapiCompliable::Adapters::ActiveRecord#sideloading_module (method)">JsonapiCompliable::Adapters::ActiveRecord#sideloading_module</a></span></li>
1935
+
1936
+ <li><span class='object_link'><a href="ActiveRecordSideloading.html" title="JsonapiCompliable::Adapters::ActiveRecordSideloading (module)">JsonapiCompliable::Adapters::ActiveRecordSideloading</a></span></li>
1937
+
1938
+ </ul>
1939
+
1940
+ </div><table class="source_code">
1941
+ <tr>
1942
+ <td>
1943
+ <pre class="lines">
1944
+
1945
+
1946
+ 249
1947
+ 250
1948
+ 251</pre>
1949
+ </td>
1950
+ <td>
1951
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 249</span>
1952
+
1953
+ <span class='kw'>def</span> <span class='id identifier rubyid_sideloading_module'>sideloading_module</span>
1954
+ <span class='const'>Module</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1955
+ <span class='kw'>end</span></pre>
1956
+ </td>
1957
+ </tr>
1958
+ </table>
1959
+ </div>
1960
+
1961
+ <div class="method_details ">
1962
+ <h3 class="signature " id="sum-instance_method">
1963
+
1964
+ #<strong>sum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+ </h3><div class="docstring">
1971
+ <div class="discussion">
1972
+
1973
+ <p>Returns the sum of the scope</p>
1974
+
1975
+
1976
+ </div>
1977
+ </div>
1978
+ <div class="tags">
1979
+
1980
+ <div class="examples">
1981
+ <p class="tag_title">Examples:</p>
1982
+
1983
+
1984
+ <p class="example_title"><div class='inline'>
1985
+ <p>ActiveRecord default</p>
1986
+ </div></p>
1987
+
1988
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1989
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1990
+ <span class='kw'>end</span></code></pre>
1991
+
1992
+ </div>
1993
+ <p class="tag_title">Parameters:</p>
1994
+ <ul class="param">
1995
+
1996
+ <li>
1997
+
1998
+ <span class='name'>scope</span>
1999
+
2000
+
2001
+ <span class='type'></span>
2002
+
2003
+
2004
+
2005
+ &mdash;
2006
+ <div class='inline'>
2007
+ <p>the scope object we are chaining</p>
2008
+ </div>
2009
+
2010
+ </li>
2011
+
2012
+ <li>
2013
+
2014
+ <span class='name'>attr</span>
2015
+
2016
+
2017
+ <span class='type'>(<tt>Symbol</tt>)</span>
2018
+
2019
+
2020
+
2021
+ &mdash;
2022
+ <div class='inline'>
2023
+ <p>corresponding stat attribute name</p>
2024
+ </div>
2025
+
2026
+ </li>
2027
+
2028
+ </ul>
2029
+
2030
+ <p class="tag_title">Returns:</p>
2031
+ <ul class="return">
2032
+
2033
+ <li>
2034
+
2035
+
2036
+ <span class='type'>(<tt>Numeric</tt>)</span>
2037
+
2038
+
2039
+
2040
+ &mdash;
2041
+ <div class='inline'>
2042
+ <p>the sum of the scope</p>
2043
+ </div>
2044
+
2045
+ </li>
2046
+
2047
+ </ul>
2048
+
2049
+ </div><table class="source_code">
2050
+ <tr>
2051
+ <td>
2052
+ <pre class="lines">
2053
+
2054
+
2055
+ 149
2056
+ 150
2057
+ 151</pre>
2058
+ </td>
2059
+ <td>
2060
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 149</span>
2061
+
2062
+ <span class='kw'>def</span> <span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
2063
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #sum in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
2064
+ <span class='kw'>end</span></pre>
2065
+ </td>
2066
+ </tr>
2067
+ </table>
2068
+ </div>
2069
+
2070
+ <div class="method_details ">
2071
+ <h3 class="signature " id="transaction-instance_method">
2072
+
2073
+ #<strong>transaction</strong>(model_class) &#x21d2; <tt>Object</tt>
2074
+
2075
+
2076
+
2077
+
2078
+
2079
+ </h3><div class="docstring">
2080
+ <div class="discussion">
2081
+
2082
+ <p>This method must <code>yield</code> the code to run within the transaction.
2083
+ This method should roll back the transaction if an error is raised.</p>
2084
+
2085
+
2086
+ </div>
2087
+ </div>
2088
+ <div class="tags">
2089
+
2090
+ <div class="examples">
2091
+ <p class="tag_title">Examples:</p>
2092
+
2093
+
2094
+ <p class="example_title"><div class='inline'>
2095
+ <p>ActiveRecord default</p>
2096
+ </div></p>
2097
+
2098
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_transaction'>transaction</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='rparen'>)</span>
2099
+ <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_transaction'>transaction</span> <span class='kw'>do</span>
2100
+ <span class='kw'>yield</span>
2101
+ <span class='kw'>end</span>
2102
+ <span class='kw'>end</span></code></pre>
2103
+
2104
+ </div>
2105
+ <p class="tag_title">Parameters:</p>
2106
+ <ul class="param">
2107
+
2108
+ <li>
2109
+
2110
+ <span class='name'>model_class</span>
2111
+
2112
+
2113
+ <span class='type'>(<tt>Class</tt>)</span>
2114
+
2115
+
2116
+
2117
+ &mdash;
2118
+ <div class='inline'>
2119
+ <p>The class we&#39;re operating on</p>
2120
+ </div>
2121
+
2122
+ </li>
2123
+
2124
+ </ul>
2125
+
2126
+
2127
+ <p class="tag_title">See Also:</p>
2128
+ <ul class="see">
2129
+
2130
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
2131
+
2132
+ </ul>
2133
+
2134
+ </div><table class="source_code">
2135
+ <tr>
2136
+ <td>
2137
+ <pre class="lines">
2138
+
2139
+
2140
+ 187
2141
+ 188
2142
+ 189</pre>
2143
+ </td>
2144
+ <td>
2145
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 187</span>
2146
+
2147
+ <span class='kw'>def</span> <span class='id identifier rubyid_transaction'>transaction</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='rparen'>)</span>
2148
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #transaction in an adapter subclass, it must yield</span><span class='tstring_end'>&#39;</span></span>
2149
+ <span class='kw'>end</span></pre>
2150
+ </td>
2151
+ </tr>
2152
+ </table>
2153
+ </div>
2154
+
2155
+ <div class="method_details ">
2156
+ <h3 class="signature " id="update-instance_method">
2157
+
2158
+ #<strong>update</strong>(model_class, update_params) &#x21d2; <tt>Object</tt>
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+ </h3><div class="docstring">
2165
+ <div class="discussion">
2166
+
2167
+ <p>Returns the model instance just created</p>
2168
+
2169
+
2170
+ </div>
2171
+ </div>
2172
+ <div class="tags">
2173
+
2174
+ <div class="examples">
2175
+ <p class="tag_title">Examples:</p>
2176
+
2177
+
2178
+ <p class="example_title"><div class='inline'>
2179
+ <p>ActiveRecord default</p>
2180
+ </div></p>
2181
+
2182
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2183
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span>
2184
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_update_attributes'>update_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2185
+ <span class='id identifier rubyid_instance'>instance</span>
2186
+ <span class='kw'>end</span></code></pre>
2187
+
2188
+ </div>
2189
+ <p class="tag_title">Parameters:</p>
2190
+ <ul class="param">
2191
+
2192
+ <li>
2193
+
2194
+ <span class='name'>model_class</span>
2195
+
2196
+
2197
+ <span class='type'>(<tt>Class</tt>)</span>
2198
+
2199
+
2200
+
2201
+ &mdash;
2202
+ <div class='inline'>
2203
+ <p>The configured model class (see Resource.model)</p>
2204
+ </div>
2205
+
2206
+ </li>
2207
+
2208
+ <li>
2209
+
2210
+ <span class='name'>update_params</span>
2211
+
2212
+
2213
+ <span class='type'>(<tt>Hash</tt>)</span>
2214
+
2215
+
2216
+
2217
+ &mdash;
2218
+ <div class='inline'>
2219
+ <p>Attributes + id</p>
2220
+ </div>
2221
+
2222
+ </li>
2223
+
2224
+ </ul>
2225
+
2226
+ <p class="tag_title">Returns:</p>
2227
+ <ul class="return">
2228
+
2229
+ <li>
2230
+
2231
+
2232
+ <span class='type'></span>
2233
+
2234
+
2235
+
2236
+
2237
+ <div class='inline'>
2238
+ <p>the model instance just created</p>
2239
+ </div>
2240
+
2241
+ </li>
2242
+
2243
+ </ul>
2244
+
2245
+ <p class="tag_title">See Also:</p>
2246
+ <ul class="see">
2247
+
2248
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
2249
+
2250
+ </ul>
2251
+
2252
+ </div><table class="source_code">
2253
+ <tr>
2254
+ <td>
2255
+ <pre class="lines">
2256
+
2257
+
2258
+ 277
2259
+ 278
2260
+ 279</pre>
2261
+ </td>
2262
+ <td>
2263
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/abstract.rb', line 277</span>
2264
+
2265
+ <span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2266
+ <span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>you must override #update in an adapter subclass</span><span class='tstring_end'>&#39;</span></span>
2267
+ <span class='kw'>end</span></pre>
2268
+ </td>
2269
+ </tr>
2270
+ </table>
2271
+ </div>
2272
+
2273
+ </div>
2274
+
2275
+ </div>
2276
+
2277
+ <div id="footer">
2278
+ Generated on Fri May 5 15:53:23 2017 by
2279
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2280
+ 0.9.9 (ruby-2.3.0).
2281
+ </div>
2282
+
2283
+ </div>
2284
+ </body>
2285
+ </html>