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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1effbc66aaa2ba49bd62f0e7605095c7e827bf83
4
- data.tar.gz: baebbb68b35036a66a2ff041f80c17b2d47decd1
2
+ SHA256:
3
+ metadata.gz: d1070be152294dd627fb6f0e98038ae626412ddd716dd1ae97137de93b1b0d70
4
+ data.tar.gz: 12fe0f44356159f58a8482b297a4e2268b9a4da3281be1e8cd1599bd1d2f0bc0
5
5
  SHA512:
6
- metadata.gz: 65d0d34c627d73ecdf3a082bc45f6597f9ae22aa066c0fa0eaea379d04ff4e38d9eca6bd5a8ef4fdfe03c44da3869bda89b7814e5a84cac8b9c0144416ead2de
7
- data.tar.gz: 3733b34a24eb28826f9ae455b3975b6a96b5796ca78d75486bd4ee18a761370ce2fa847c6dae080e8486b79d062c2f0fbbc60f33e9781b871d676e7edf3da927
6
+ metadata.gz: 7d3086df6face4380f6596be5b9dea2dc61a72e3672c2e74a175e9236cd0a18fcac749e2eeef1a8df8724e232ac816c0ca9cdec425da7a3912c997a3f91b1037
7
+ data.tar.gz: eee38bbee623810f27dd48d925cc456abd3a6ccbcb8773cfb4945afea29aa5da92bc6f61cbd57601f0c5ed613b4f9c4a839621bc91f33e727282d66d96e4e9ff
@@ -1,4 +1,9 @@
1
1
 
2
+ 0.4.0 10/20/2020
3
+ ================
4
+
5
+ Add an `IntrospectiveGrape.config.skip_object_reload = true` option.
6
+
2
7
  0.3.9 04/01/2019
3
8
  ================
4
9
 
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:
@@ -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
@@ -13,6 +13,6 @@ module IntrospectiveGrape
13
13
  end
14
14
 
15
15
  def self.config
16
- @config = OpenStruct.new(camelize_parameters: true)
16
+ @config = OpenStruct.new(camelize_parameters: true, skip_object_reload: false)
17
17
  end
18
18
  end
@@ -250,7 +250,12 @@ module IntrospectiveGrape
250
250
 
251
251
  default_includes = routes.first.klass.default_includes(routes.first.model)
252
252
 
253
- present klass.find_leaf(routes, @model.class.includes(default_includes).find(@model.id), params), with: "#{klass}::#{model}Entity".constantize
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
 
@@ -1,3 +1,3 @@
1
1
  module IntrospectiveGrape
2
- VERSION = "0.3.9".freeze
2
+ VERSION = "0.4.0".freeze
3
3
  end
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.3.9
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: 2019-04-03 00:00:00.000000000 Z
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
- rubyforge_project:
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