jsonapi_actions 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/jsonapi_actions/version.rb +1 -1
- data/lib/jsonapi_actions.rb +25 -8
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: adf742b138dbab22fae3dce7055502194e04bc8817c0af104d974fc767a6bdf5
|
|
4
|
+
data.tar.gz: 2d6e39470f0d0c22ffbbcb742b8f0eae2aecc4eb7b90c94e9ac5f5cf6819bd01
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d65af3d4872162bd162df4894b454fe4f204488976bcf65e2bbc6dd3085ba0f46079e899352cdb32f5457d7298077784324a93e8288a30a549732c1bff5cfb56
|
|
7
|
+
data.tar.gz: 237490111ce9cda4f310bd90b6e9bfe092a6093a8403d3daf6fdfe54aab951d231deac03e29c8291c537233cc01b052d71f128f9a21c6899534d3fc798d55829
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
jsonapi_actions (0.1.
|
|
4
|
+
jsonapi_actions (0.1.2)
|
|
5
5
|
kaminari (>= 1.0, < 2.0)
|
|
6
6
|
rails (>= 4.0, < 7.0)
|
|
7
7
|
|
|
@@ -99,7 +99,7 @@ GEM
|
|
|
99
99
|
nio4r (2.5.2)
|
|
100
100
|
nokogiri (1.10.5)
|
|
101
101
|
mini_portile2 (~> 2.4.0)
|
|
102
|
-
rack (2.0.
|
|
102
|
+
rack (2.0.8)
|
|
103
103
|
rack-test (1.1.0)
|
|
104
104
|
rack (>= 1.0, < 3)
|
|
105
105
|
rails (6.0.1)
|
data/lib/jsonapi_actions.rb
CHANGED
|
@@ -120,11 +120,11 @@ module JsonapiActions
|
|
|
120
120
|
|
|
121
121
|
def page
|
|
122
122
|
@page ||= begin
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
page = {}
|
|
124
|
+
page[:number] = (params.dig(:page, :number) || 1).to_i
|
|
125
|
+
page[:size] = [[(params.dig(:page, :size) || 20).to_i, 1000].min, 1].max
|
|
126
|
+
page
|
|
127
|
+
end
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def set_record
|
|
@@ -194,10 +194,27 @@ module JsonapiActions
|
|
|
194
194
|
end
|
|
195
195
|
|
|
196
196
|
def serializer(data = nil)
|
|
197
|
-
self.class.serializer
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
if self.class.serializer
|
|
198
|
+
self.class.serializer
|
|
199
|
+
else
|
|
200
200
|
"#{model.name}Serializer".constantize
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
rescue NoMethodError, NameError
|
|
204
|
+
serializer_lookup(data)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def serializer_lookup(data)
|
|
208
|
+
serializer_classes = [
|
|
209
|
+
data.try(:serializer_class),
|
|
210
|
+
"#{data.class.try(:name)}Serializer".try(:constantize),
|
|
211
|
+
data.try(:first).try(:serializer_class),
|
|
212
|
+
"#{data.try(:first).class.try(:name)}Serializer".try(:constantize)
|
|
213
|
+
].compact
|
|
214
|
+
|
|
215
|
+
raise 'Unknown serializer' if serializer_classes.empty?
|
|
216
|
+
|
|
217
|
+
serializer_classes.first
|
|
201
218
|
end
|
|
202
219
|
|
|
203
220
|
def eager_load(records)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsonapi_actions
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Pheasey
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -138,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
139
|
version: '0'
|
|
140
140
|
requirements: []
|
|
141
|
-
|
|
142
|
-
rubygems_version: 2.7.8
|
|
141
|
+
rubygems_version: 3.0.8
|
|
143
142
|
signing_key:
|
|
144
143
|
specification_version: 4
|
|
145
144
|
summary: Rails JSONAPI Controller Actions
|