introspective_grape 0.3.9 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/README.md +14 -0
- data/introspective_grape.gemspec +1 -1
- data/lib/introspective_grape.rb +1 -1
- data/lib/introspective_grape/api.rb +6 -1
- data/lib/introspective_grape/version.rb +1 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d1070be152294dd627fb6f0e98038ae626412ddd716dd1ae97137de93b1b0d70
|
4
|
+
data.tar.gz: 12fe0f44356159f58a8482b297a4e2268b9a4da3281be1e8cd1599bd1d2f0bc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d3086df6face4380f6596be5b9dea2dc61a72e3672c2e74a175e9236cd0a18fcac749e2eeef1a8df8724e232ac816c0ca9cdec425da7a3912c997a3f91b1037
|
7
|
+
data.tar.gz: eee38bbee623810f27dd48d925cc456abd3a6ccbcb8773cfb4945afea29aa5da92bc6f61cbd57601f0c5ed613b4f9c4a839621bc91f33e727282d66d96e4e9ff
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -49,6 +49,8 @@ And bundle install.
|
|
49
49
|
|
50
50
|
## Grape Configuration
|
51
51
|
|
52
|
+
### Camelization
|
53
|
+
|
52
54
|
IntrospectiveGrape's default behavior is to camelize all outputs and snake case all inputs. To camel case all your json output you'll need to use its formatter in your API:
|
53
55
|
|
54
56
|
```
|
@@ -61,6 +63,18 @@ You can disable this behavior by setting `IntrospectiveGrape.config.camelize_par
|
|
61
63
|
|
62
64
|
To include this behavior in your test coverage you need to either access the API's params hash or you can format the response body to `JSON.parse(response.body).with_snake_keys` in a helper method with the `using CamelSnakeKeys` refinement.
|
63
65
|
|
66
|
+
### Reloading an object after an update request
|
67
|
+
|
68
|
+
By default the gem reloads the object instance before presenting the updated model, a lazy but
|
69
|
+
effective workaround to updates that may not propagate in the working instance due to actions
|
70
|
+
a user may take in hooks, or some updates to has_many :through associations. We want to put up
|
71
|
+
APIs with haste rather than digging our way out of tricky minutae that can be handled later as
|
72
|
+
technical debt.
|
73
|
+
|
74
|
+
This behavior can be disabled by setting `IntrospectiveGrape.config.skip_object_reload = true`,
|
75
|
+
when you have time for technical debt you can toggle it and work on fixing broken tests (you
|
76
|
+
did take the time to write comprehensive test coverage, didn't you?).
|
77
|
+
|
64
78
|
## Authentication and authorization
|
65
79
|
|
66
80
|
Authentication and authorization are presently enforced on every endpoint. If you have named the authentication helper method in Grape something other than "authenticate!" or "authorize!" you can set it with:
|
data/introspective_grape.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "rails", '> 5.0.0'
|
24
24
|
|
25
25
|
# grape 1.0.0 breaks the pagination solution
|
26
|
-
s.add_dependency 'grape', '~> 1.2.0'
|
26
|
+
s.add_dependency 'grape', ['~> 1.2.0', '< 1.2.5']
|
27
27
|
s.add_dependency 'grape-entity'
|
28
28
|
s.add_dependency 'grape-swagger'
|
29
29
|
s.add_dependency 'kaminari' #, '< 1.0' # version 1.0.0 breaks
|
data/lib/introspective_grape.rb
CHANGED
@@ -250,7 +250,12 @@ module IntrospectiveGrape
|
|
250
250
|
|
251
251
|
default_includes = routes.first.klass.default_includes(routes.first.model)
|
252
252
|
|
253
|
-
|
253
|
+
if IntrospectiveGrape.config.skip_object_reload
|
254
|
+
present klass.find_leaf(routes, @model, params), with: "#{klass}::#{model}Entity".constantize
|
255
|
+
else
|
256
|
+
default_includes = routes.first.klass.default_includes(routes.first.model)
|
257
|
+
present klass.find_leaf(routes, @model.class.includes(default_includes).find(@model.id), params), with: "#{klass}::#{model}Entity".constantize
|
258
|
+
end
|
254
259
|
end
|
255
260
|
end
|
256
261
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: introspective_grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Buermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.2.0
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.2.5
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: 1.2.0
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.2.5
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: grape-entity
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -413,8 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
419
|
- !ruby/object:Gem::Version
|
414
420
|
version: '0'
|
415
421
|
requirements: []
|
416
|
-
|
417
|
-
rubygems_version: 2.5.1
|
422
|
+
rubygems_version: 3.1.2
|
418
423
|
signing_key:
|
419
424
|
specification_version: 4
|
420
425
|
summary: Introspectively configure deeply nested RESTful Grape APIs for ActiveRecord
|