rest-api-generator 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a42f65c1630afe3db2bc1acb7c66272b9703e61ac761d509b0561e6c9369d7df
4
- data.tar.gz: 898e903b7b81efa687f272a18ec7179f42ac566da404b1f046002b74345c9f77
3
+ metadata.gz: bb2c1297296ab8fb5b53e9eaa49a1569c56a564e60058f206118d9baa2423935
4
+ data.tar.gz: d6b146e4fdca8a433c2244a2baf73ef66b3f4e4c579fe497a0eef04766b4e194
5
5
  SHA512:
6
- metadata.gz: 83e49d124a05cee3c742a69d5d2b1f798014e331c2a662a2bd7b0b19cb99ca45d66bdd290fa996e0c7e969d302fc9ecd49e9c69554836fe582d55adbb06f8f66
7
- data.tar.gz: 14bd2117229d7cc2cb6b17371f7d0767720e3b6051ddcfc5fa6fb95aec438c29db25800ec5d44505284e4c56ba817e36666fa9118262228d5ab6086d740b0016
6
+ metadata.gz: 9c4cdc211df26b7d4aad4e6cc1aa61d9d3cec342b3482d0bb088ffb78a006eb1b7a262b7b2ef51afb3812cbef41b6b04e335dd103ce9be511773fcf603c729fe
7
+ data.tar.gz: b1e5c67523466113cfb88f99c842c4b26b0e9700016b8d683e53f27ce0f8f4ad24b811f3b0c1b0b2e52fc211c4c5d7f7aff85a7612640efcc2446b52ea0e1658
data/Gemfile.lock CHANGED
@@ -9,108 +9,123 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actioncable (7.0.4.3)
13
- actionpack (= 7.0.4.3)
14
- activesupport (= 7.0.4.3)
12
+ actioncable (7.2.0)
13
+ actionpack (= 7.2.0)
14
+ activesupport (= 7.2.0)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailbox (7.0.4.3)
18
- actionpack (= 7.0.4.3)
19
- activejob (= 7.0.4.3)
20
- activerecord (= 7.0.4.3)
21
- activestorage (= 7.0.4.3)
22
- activesupport (= 7.0.4.3)
23
- mail (>= 2.7.1)
24
- net-imap
25
- net-pop
26
- net-smtp
27
- actionmailer (7.0.4.3)
28
- actionpack (= 7.0.4.3)
29
- actionview (= 7.0.4.3)
30
- activejob (= 7.0.4.3)
31
- activesupport (= 7.0.4.3)
32
- mail (~> 2.5, >= 2.5.4)
33
- net-imap
34
- net-pop
35
- net-smtp
36
- rails-dom-testing (~> 2.0)
37
- actionpack (7.0.4.3)
38
- actionview (= 7.0.4.3)
39
- activesupport (= 7.0.4.3)
40
- rack (~> 2.0, >= 2.2.0)
17
+ zeitwerk (~> 2.6)
18
+ actionmailbox (7.2.0)
19
+ actionpack (= 7.2.0)
20
+ activejob (= 7.2.0)
21
+ activerecord (= 7.2.0)
22
+ activestorage (= 7.2.0)
23
+ activesupport (= 7.2.0)
24
+ mail (>= 2.8.0)
25
+ actionmailer (7.2.0)
26
+ actionpack (= 7.2.0)
27
+ actionview (= 7.2.0)
28
+ activejob (= 7.2.0)
29
+ activesupport (= 7.2.0)
30
+ mail (>= 2.8.0)
31
+ rails-dom-testing (~> 2.2)
32
+ actionpack (7.2.0)
33
+ actionview (= 7.2.0)
34
+ activesupport (= 7.2.0)
35
+ nokogiri (>= 1.8.5)
36
+ racc
37
+ rack (>= 2.2.4, < 3.2)
38
+ rack-session (>= 1.0.1)
41
39
  rack-test (>= 0.6.3)
42
- rails-dom-testing (~> 2.0)
43
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
- actiontext (7.0.4.3)
45
- actionpack (= 7.0.4.3)
46
- activerecord (= 7.0.4.3)
47
- activestorage (= 7.0.4.3)
48
- activesupport (= 7.0.4.3)
40
+ rails-dom-testing (~> 2.2)
41
+ rails-html-sanitizer (~> 1.6)
42
+ useragent (~> 0.16)
43
+ actiontext (7.2.0)
44
+ actionpack (= 7.2.0)
45
+ activerecord (= 7.2.0)
46
+ activestorage (= 7.2.0)
47
+ activesupport (= 7.2.0)
49
48
  globalid (>= 0.6.0)
50
49
  nokogiri (>= 1.8.5)
51
- actionview (7.0.4.3)
52
- activesupport (= 7.0.4.3)
50
+ actionview (7.2.0)
51
+ activesupport (= 7.2.0)
53
52
  builder (~> 3.1)
54
- erubi (~> 1.4)
55
- rails-dom-testing (~> 2.0)
56
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
- active_model_serializers (0.10.13)
58
- actionpack (>= 4.1, < 7.1)
59
- activemodel (>= 4.1, < 7.1)
53
+ erubi (~> 1.11)
54
+ rails-dom-testing (~> 2.2)
55
+ rails-html-sanitizer (~> 1.6)
56
+ active_model_serializers (0.10.14)
57
+ actionpack (>= 4.1)
58
+ activemodel (>= 4.1)
60
59
  case_transform (>= 0.2)
61
60
  jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
62
- activejob (7.0.4.3)
63
- activesupport (= 7.0.4.3)
61
+ activejob (7.2.0)
62
+ activesupport (= 7.2.0)
64
63
  globalid (>= 0.3.6)
65
- activemodel (7.0.4.3)
66
- activesupport (= 7.0.4.3)
67
- activerecord (7.0.4.3)
68
- activemodel (= 7.0.4.3)
69
- activesupport (= 7.0.4.3)
70
- activestorage (7.0.4.3)
71
- actionpack (= 7.0.4.3)
72
- activejob (= 7.0.4.3)
73
- activerecord (= 7.0.4.3)
74
- activesupport (= 7.0.4.3)
64
+ activemodel (7.2.0)
65
+ activesupport (= 7.2.0)
66
+ activerecord (7.2.0)
67
+ activemodel (= 7.2.0)
68
+ activesupport (= 7.2.0)
69
+ timeout (>= 0.4.0)
70
+ activestorage (7.2.0)
71
+ actionpack (= 7.2.0)
72
+ activejob (= 7.2.0)
73
+ activerecord (= 7.2.0)
74
+ activesupport (= 7.2.0)
75
75
  marcel (~> 1.0)
76
- mini_mime (>= 1.1.0)
77
- activesupport (7.0.4.3)
78
- concurrent-ruby (~> 1.0, >= 1.0.2)
76
+ activesupport (7.2.0)
77
+ base64
78
+ bigdecimal
79
+ concurrent-ruby (~> 1.0, >= 1.3.1)
80
+ connection_pool (>= 2.2.5)
81
+ drb
79
82
  i18n (>= 1.6, < 2)
83
+ logger (>= 1.4.2)
80
84
  minitest (>= 5.1)
81
- tzinfo (~> 2.0)
82
- addressable (2.8.4)
83
- public_suffix (>= 2.0.2, < 6.0)
84
- ammeter (1.1.5)
85
+ securerandom (>= 0.3)
86
+ tzinfo (~> 2.0, >= 2.0.5)
87
+ addressable (2.8.7)
88
+ public_suffix (>= 2.0.2, < 7.0)
89
+ ammeter (1.1.7)
85
90
  activesupport (>= 3.0)
86
91
  railties (>= 3.0)
87
92
  rspec-rails (>= 2.2)
88
- anyway_config (2.4.1)
89
- ruby-next-core (>= 0.14.0)
93
+ anyway_config (2.6.4)
94
+ ruby-next-core (~> 1.0)
90
95
  ast (2.4.2)
91
- builder (3.2.4)
96
+ base64 (0.2.0)
97
+ bigdecimal (3.1.8)
98
+ builder (3.3.0)
92
99
  case_transform (0.2)
93
100
  activesupport
94
- concurrent-ruby (1.2.2)
101
+ concurrent-ruby (1.3.4)
102
+ connection_pool (2.4.1)
95
103
  crass (1.0.6)
96
104
  database_cleaner (2.0.2)
97
105
  database_cleaner-active_record (>= 2, < 3)
98
- database_cleaner-active_record (2.1.0)
106
+ database_cleaner-active_record (2.2.0)
99
107
  activerecord (>= 5.a)
100
108
  database_cleaner-core (~> 2.0.0)
101
109
  database_cleaner-core (2.0.1)
102
- date (3.3.3)
103
- diff-lcs (1.5.0)
104
- erubi (1.12.0)
105
- globalid (1.1.0)
106
- activesupport (>= 5.0)
107
- i18n (1.13.0)
110
+ date (3.3.4)
111
+ diff-lcs (1.5.1)
112
+ drb (2.2.1)
113
+ erubi (1.13.0)
114
+ globalid (1.2.1)
115
+ activesupport (>= 6.1)
116
+ i18n (1.14.5)
108
117
  concurrent-ruby (~> 1.0)
109
- json (2.6.3)
110
- json-schema (3.0.0)
118
+ io-console (0.7.2)
119
+ irb (1.14.0)
120
+ rdoc (>= 4.0.0)
121
+ reline (>= 0.4.2)
122
+ json (2.7.2)
123
+ json-schema (4.3.1)
111
124
  addressable (>= 2.8)
112
125
  jsonapi-renderer (0.2.2)
113
- loofah (2.21.2)
126
+ language_server-protocol (3.17.0.3)
127
+ logger (1.6.0)
128
+ loofah (2.22.0)
114
129
  crass (~> 1.0.2)
115
130
  nokogiri (>= 1.12.0)
116
131
  mail (2.8.1)
@@ -118,82 +133,100 @@ GEM
118
133
  net-imap
119
134
  net-pop
120
135
  net-smtp
121
- marcel (1.0.2)
122
- method_source (1.0.0)
123
- mini_mime (1.1.2)
124
- mini_portile2 (2.8.2)
125
- minitest (5.18.0)
126
- net-imap (0.3.4)
136
+ marcel (1.0.4)
137
+ mini_mime (1.1.5)
138
+ mini_portile2 (2.8.7)
139
+ minitest (5.25.0)
140
+ net-imap (0.4.14)
127
141
  date
128
142
  net-protocol
129
143
  net-pop (0.1.2)
130
144
  net-protocol
131
- net-protocol (0.2.1)
145
+ net-protocol (0.2.2)
132
146
  timeout
133
- net-smtp (0.3.3)
147
+ net-smtp (0.5.0)
134
148
  net-protocol
135
- nio4r (2.5.9)
136
- nokogiri (1.14.4)
137
- mini_portile2 (~> 2.8.0)
149
+ nio4r (2.7.3)
150
+ nokogiri (1.16.7)
151
+ mini_portile2 (~> 2.8.2)
138
152
  racc (~> 1.4)
139
- nokogiri (1.14.4-x86_64-linux)
153
+ nokogiri (1.16.7-x86_64-linux)
140
154
  racc (~> 1.4)
141
- oj (3.14.3)
142
- pagy (6.0.4)
143
- panko_serializer (0.7.9)
155
+ oj (3.16.5)
156
+ bigdecimal (>= 3.0)
157
+ ostruct (>= 0.2)
158
+ ostruct (0.6.0)
159
+ pagy (9.0.5)
160
+ panko_serializer (0.8.2)
144
161
  activesupport
145
162
  oj (> 3.11.0, < 4.0.0)
146
- parallel (1.23.0)
147
- parser (3.2.2.1)
163
+ parallel (1.26.2)
164
+ parser (3.3.4.2)
148
165
  ast (~> 2.4.1)
149
- public_suffix (5.0.1)
150
- racc (1.6.2)
151
- rack (2.2.7)
166
+ racc
167
+ psych (5.1.2)
168
+ stringio
169
+ public_suffix (6.0.1)
170
+ racc (1.8.1)
171
+ rack (3.1.7)
172
+ rack-session (2.0.0)
173
+ rack (>= 3.0.0)
152
174
  rack-test (2.1.0)
153
175
  rack (>= 1.3)
154
- rails (7.0.4.3)
155
- actioncable (= 7.0.4.3)
156
- actionmailbox (= 7.0.4.3)
157
- actionmailer (= 7.0.4.3)
158
- actionpack (= 7.0.4.3)
159
- actiontext (= 7.0.4.3)
160
- actionview (= 7.0.4.3)
161
- activejob (= 7.0.4.3)
162
- activemodel (= 7.0.4.3)
163
- activerecord (= 7.0.4.3)
164
- activestorage (= 7.0.4.3)
165
- activesupport (= 7.0.4.3)
176
+ rackup (2.1.0)
177
+ rack (>= 3)
178
+ webrick (~> 1.8)
179
+ rails (7.2.0)
180
+ actioncable (= 7.2.0)
181
+ actionmailbox (= 7.2.0)
182
+ actionmailer (= 7.2.0)
183
+ actionpack (= 7.2.0)
184
+ actiontext (= 7.2.0)
185
+ actionview (= 7.2.0)
186
+ activejob (= 7.2.0)
187
+ activemodel (= 7.2.0)
188
+ activerecord (= 7.2.0)
189
+ activestorage (= 7.2.0)
190
+ activesupport (= 7.2.0)
166
191
  bundler (>= 1.15.0)
167
- railties (= 7.0.4.3)
168
- rails-dom-testing (2.0.3)
169
- activesupport (>= 4.2.0)
192
+ railties (= 7.2.0)
193
+ rails-dom-testing (2.2.0)
194
+ activesupport (>= 5.0.0)
195
+ minitest
170
196
  nokogiri (>= 1.6)
171
- rails-html-sanitizer (1.5.0)
172
- loofah (~> 2.19, >= 2.19.1)
173
- railties (7.0.4.3)
174
- actionpack (= 7.0.4.3)
175
- activesupport (= 7.0.4.3)
176
- method_source
197
+ rails-html-sanitizer (1.6.0)
198
+ loofah (~> 2.21)
199
+ nokogiri (~> 1.14)
200
+ railties (7.2.0)
201
+ actionpack (= 7.2.0)
202
+ activesupport (= 7.2.0)
203
+ irb (~> 1.13)
204
+ rackup (>= 1.0.0)
177
205
  rake (>= 12.2)
178
- thor (~> 1.0)
179
- zeitwerk (~> 2.5)
206
+ thor (~> 1.0, >= 1.2.2)
207
+ zeitwerk (~> 2.6)
180
208
  rainbow (3.1.1)
181
- rake (13.0.6)
182
- regexp_parser (2.8.0)
183
- rexml (3.2.5)
184
- rspec (3.12.0)
185
- rspec-core (~> 3.12.0)
186
- rspec-expectations (~> 3.12.0)
187
- rspec-mocks (~> 3.12.0)
188
- rspec-core (3.12.2)
189
- rspec-support (~> 3.12.0)
190
- rspec-expectations (3.12.3)
209
+ rake (13.2.1)
210
+ rdoc (6.7.0)
211
+ psych (>= 4.0.0)
212
+ regexp_parser (2.9.2)
213
+ reline (0.5.9)
214
+ io-console (~> 0.5)
215
+ rexml (3.3.5)
216
+ strscan
217
+ rspec (3.13.0)
218
+ rspec-core (~> 3.13.0)
219
+ rspec-expectations (~> 3.13.0)
220
+ rspec-mocks (~> 3.13.0)
221
+ rspec-core (3.13.0)
222
+ rspec-support (~> 3.13.0)
223
+ rspec-expectations (3.13.1)
191
224
  diff-lcs (>= 1.2.0, < 2.0)
192
- rspec-support (~> 3.12.0)
193
- rspec-mocks (3.12.5)
225
+ rspec-support (~> 3.13.0)
226
+ rspec-mocks (3.13.1)
194
227
  diff-lcs (>= 1.2.0, < 2.0)
195
- rspec-support (~> 3.12.0)
196
- rspec-rails (6.0.2)
228
+ rspec-support (~> 3.13.0)
229
+ rspec-rails (6.0.4)
197
230
  actionpack (>= 6.1)
198
231
  activesupport (>= 6.1)
199
232
  railties (>= 6.1)
@@ -201,70 +234,81 @@ GEM
201
234
  rspec-expectations (~> 3.12)
202
235
  rspec-mocks (~> 3.12)
203
236
  rspec-support (~> 3.12)
204
- rspec-support (3.12.0)
205
- rswag (2.9.0)
206
- rswag-api (= 2.9.0)
207
- rswag-specs (= 2.9.0)
208
- rswag-ui (= 2.9.0)
209
- rswag-api (2.9.0)
210
- railties (>= 3.1, < 7.1)
211
- rswag-specs (2.9.0)
212
- activesupport (>= 3.1, < 7.1)
213
- json-schema (>= 2.2, < 4.0)
214
- railties (>= 3.1, < 7.1)
237
+ rspec-support (3.13.1)
238
+ rswag (2.14.0)
239
+ rswag-api (= 2.14.0)
240
+ rswag-specs (= 2.14.0)
241
+ rswag-ui (= 2.14.0)
242
+ rswag-api (2.14.0)
243
+ activesupport (>= 5.2, < 8.0)
244
+ railties (>= 5.2, < 8.0)
245
+ rswag-specs (2.14.0)
246
+ activesupport (>= 5.2, < 8.0)
247
+ json-schema (>= 2.2, < 5.0)
248
+ railties (>= 5.2, < 8.0)
215
249
  rspec-core (>= 2.14)
216
- rswag-ui (2.9.0)
217
- actionpack (>= 3.1, < 7.1)
218
- railties (>= 3.1, < 7.1)
219
- rubocop (1.51.0)
250
+ rswag-ui (2.14.0)
251
+ actionpack (>= 5.2, < 8.0)
252
+ railties (>= 5.2, < 8.0)
253
+ rubocop (1.64.1)
220
254
  json (~> 2.3)
255
+ language_server-protocol (>= 3.17.0)
221
256
  parallel (~> 1.10)
222
- parser (>= 3.2.0.0)
257
+ parser (>= 3.3.0.2)
223
258
  rainbow (>= 2.2.2, < 4.0)
224
259
  regexp_parser (>= 1.8, < 3.0)
225
260
  rexml (>= 3.2.5, < 4.0)
226
- rubocop-ast (>= 1.28.0, < 2.0)
261
+ rubocop-ast (>= 1.31.1, < 2.0)
227
262
  ruby-progressbar (~> 1.7)
228
263
  unicode-display_width (>= 2.4.0, < 3.0)
229
- rubocop-ast (1.28.1)
230
- parser (>= 3.2.1.0)
231
- rubocop-capybara (2.18.0)
264
+ rubocop-ast (1.32.0)
265
+ parser (>= 3.3.1.0)
266
+ rubocop-capybara (2.21.0)
232
267
  rubocop (~> 1.41)
233
- rubocop-factory_bot (2.22.0)
234
- rubocop (~> 1.33)
235
- rubocop-performance (1.17.1)
236
- rubocop (>= 1.7.0, < 2.0)
237
- rubocop-ast (>= 0.4.0)
238
- rubocop-rails (2.19.1)
268
+ rubocop-factory_bot (2.26.1)
269
+ rubocop (~> 1.61)
270
+ rubocop-performance (1.21.0)
271
+ rubocop (>= 1.48.1, < 2.0)
272
+ rubocop-ast (>= 1.31.1, < 2.0)
273
+ rubocop-rails (2.25.0)
239
274
  activesupport (>= 4.2.0)
240
275
  rack (>= 1.1)
241
276
  rubocop (>= 1.33.0, < 2.0)
242
- rubocop-rspec (2.22.0)
243
- rubocop (~> 1.33)
277
+ rubocop-ast (>= 1.31.1, < 2.0)
278
+ rubocop-rspec (2.29.2)
279
+ rubocop (~> 1.40)
244
280
  rubocop-capybara (~> 2.17)
245
281
  rubocop-factory_bot (~> 2.22)
246
- rubocop-shopify (2.13.0)
247
- rubocop (~> 1.50)
248
- ruby-next-core (0.15.3)
282
+ rubocop-rspec_rails (~> 2.28)
283
+ rubocop-rspec_rails (2.29.1)
284
+ rubocop (~> 1.61)
285
+ rubocop-shopify (2.15.1)
286
+ rubocop (~> 1.51)
287
+ ruby-next-core (1.0.3)
249
288
  ruby-progressbar (1.13.0)
250
- sqlite3 (1.6.2)
289
+ securerandom (0.3.1)
290
+ sqlite3 (2.0.4)
251
291
  mini_portile2 (~> 2.8.0)
252
- sqlite3 (1.6.2-x86_64-linux)
253
- switchcop (0.1.3)
254
- rubocop (~> 1.48)
255
- rubocop-performance (~> 1.16)
256
- rubocop-rails (~> 2.18)
257
- rubocop-rspec (~> 2.19)
258
- rubocop-shopify (~> 2.12)
259
- thor (1.2.2)
260
- timeout (0.3.2)
292
+ sqlite3 (2.0.4-x86_64-linux-gnu)
293
+ stringio (3.1.1)
294
+ strscan (3.1.0)
295
+ switchcop (0.1.7)
296
+ rubocop (= 1.64.1)
297
+ rubocop-performance (= 1.21.0)
298
+ rubocop-rails (= 2.25.0)
299
+ rubocop-rspec (= 2.29.2)
300
+ rubocop-shopify (= 2.15.1)
301
+ thor (1.3.1)
302
+ timeout (0.4.1)
261
303
  tzinfo (2.0.6)
262
304
  concurrent-ruby (~> 1.0)
263
- unicode-display_width (2.4.2)
264
- websocket-driver (0.7.5)
305
+ unicode-display_width (2.5.0)
306
+ useragent (0.16.10)
307
+ webrick (1.8.1)
308
+ websocket-driver (0.7.6)
265
309
  websocket-extensions (>= 0.1.0)
266
310
  websocket-extensions (0.1.5)
267
- zeitwerk (2.6.8)
311
+ zeitwerk (2.6.17)
268
312
 
269
313
  PLATFORMS
270
314
  ruby
@@ -285,4 +329,4 @@ DEPENDENCIES
285
329
  switchcop
286
330
 
287
331
  BUNDLED WITH
288
- 2.3.3
332
+ 2.4.19
data/README.md CHANGED
@@ -40,6 +40,13 @@ Following [Switch Dreams's](https://www.switchdreams.com.br/]) coding practices,
40
40
  - Select fields
41
41
  - User auth module
42
42
 
43
+ ## Other alternatives
44
+
45
+ This gem resolves a very common problem so the are a lot of alternative in the market.
46
+
47
+ - [decent_exposure](https://github.com/hashrocket/decent_exposure)
48
+ - [resourcerer](https://github.com/ElMassimo/resourcerer)
49
+
43
50
  ## Development
44
51
 
45
52
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can
@@ -10,7 +10,7 @@ module RestApiGenerator
10
10
  before_action :set_resource, only: [:show, :update, :destroy]
11
11
 
12
12
  def index
13
- @resources = resources
13
+ set_all_resources
14
14
  @resources = @resources.filter_resource(params_for_filter) if resource_class.include?(Filterable)
15
15
  @resources = @resources.order(ordering_params(params[:sort])) if params[:sort]
16
16
  if pagination
@@ -40,6 +40,12 @@ module RestApiGenerator
40
40
 
41
41
  private
42
42
 
43
+ def set_all_resources
44
+ run_callbacks :set_all_resources do
45
+ @resources = resources
46
+ end
47
+ end
48
+
43
49
  def resources
44
50
  @parent_resource.send(resource_class.to_s.downcase.pluralize)
45
51
  end
@@ -7,8 +7,9 @@ module RestApiGenerator
7
7
  include Serializable
8
8
 
9
9
  before_action :set_resource, only: [:show, :update, :destroy]
10
+
10
11
  def index
11
- @resources = resource_class.all
12
+ set_all_resources
12
13
  @resources = @resources.filter_resource(params_for_filter) if resource_class.include?(Filterable)
13
14
  @resources = @resources.order(ordering_params(params[:sort])) if params[:sort]
14
15
  if pagination
@@ -68,6 +69,12 @@ module RestApiGenerator
68
69
  end
69
70
  end
70
71
 
72
+ def set_all_resources
73
+ run_callbacks :set_all_resources do
74
+ @resources = resource_class.all
75
+ end
76
+ end
77
+
71
78
  # UsersController => User
72
79
  def resource_by_controller_name(controller_name = self.class.to_s)
73
80
  controller_name.split(Regexp.union(["Controller", "::"]))[-1].singularize.constantize
@@ -51,11 +51,9 @@ module RestApiGenerator
51
51
  end
52
52
 
53
53
  def build_model_attributes
54
- model_attributes = []
55
- attributes.each do |attribute|
56
- model_attributes << "#{attribute.name}:#{attribute.type}"
54
+ attributes.map do |attribute|
55
+ "#{attribute.name}:#{attribute.type}"
57
56
  end
58
- model_attributes
59
57
  end
60
58
  end
61
59
  end
@@ -8,22 +8,29 @@ module RestApiGenerator
8
8
  included do
9
9
  define_callbacks :set_resource
10
10
  define_callbacks :set_parent_resource
11
+ define_callbacks :set_all_resources
11
12
  end
12
13
 
13
14
  module ClassMethods
14
15
  # Code from rails source code
15
16
  [:before, :after, :around].each do |callback|
16
- define_method "#{callback}_set_resource" do |*names, &blk|
17
+ define_method :"#{callback}_set_resource" do |*names, &blk|
17
18
  _insert_callbacks(names, blk) do |name, options|
18
19
  set_callback(:set_resource, callback, name, options)
19
20
  end
20
21
  end
21
22
 
22
- define_method "#{callback}_set_parent_resource" do |*names, &blk|
23
+ define_method :"#{callback}_set_parent_resource" do |*names, &blk|
23
24
  _insert_callbacks(names, blk) do |name, options|
24
25
  set_callback(:set_parent_resource, callback, name, options)
25
26
  end
26
27
  end
28
+
29
+ define_method :"#{callback}_set_all_resources" do |*names, &blk|
30
+ _insert_callbacks(names, blk) do |name, options|
31
+ set_callback(:set_all_resources, callback, name, options)
32
+ end
33
+ end
27
34
  end
28
35
  end
29
36
  end
@@ -21,7 +21,7 @@ module RestApiGenerator
21
21
  def filter_resource(params)
22
22
  results = where(nil)
23
23
  params.each do |key, value|
24
- results = results.public_send("filter_by_#{key}", value) if value.present?
24
+ results = results.public_send(:"filter_by_#{key}", value) if value.present?
25
25
  end
26
26
  results
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RestApiGenerator
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest-api-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PedroAugustoRamalhoDuarte
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2024-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubygems_version: 3.3.3
194
+ rubygems_version: 3.5.16
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Build a Ruby on Rails REST API faster