olive_branch 2.1.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/olive_branch/middleware.rb +3 -1
- data/lib/olive_branch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb564e7a107ec4a4ec603c123a1712b4cc564091606a42acf3a420ef61d42a8c
|
4
|
+
data.tar.gz: 980afa4b827e039484b1e0a9983c49cdcb884c1202c5a984ab008ecf65b0df0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69c7a3da07246dd9566a5fb62b276f2fd31e085066a8369d3e95d49c21ee0f6592c6718eeeccf4335be6b7062af82491772919c7e37cb831cc1d949b4acb906f
|
7
|
+
data.tar.gz: c4662471213424e5c06ccf547b90745b75a8addd9ba6f4382ce306f47fe3af328f062144454a6f69d3a5550dc1141c7d7f1cde1a8334afd146594b689cb91f27
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ config.middleware.use OliveBranch::Middleware
|
|
21
21
|
|
22
22
|
## Use
|
23
23
|
|
24
|
-
Include a `
|
24
|
+
Include a `Key-Inflection` header with values of `camel`, `dash`, `snake` or `pascal` in your JSON API requests.
|
25
25
|
|
26
26
|
For more examples, see [our blog post](https://www.viget.com/articles/introducing-olivebranch).
|
27
27
|
|
@@ -48,7 +48,13 @@ end
|
|
48
48
|
config.middleware.use OliveBranch::Middleware, camelize: FastCamel.method(:camelize)
|
49
49
|
```
|
50
50
|
|
51
|
-
|
51
|
+
Default inflection header key can be changed like
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
config.middleware.use OliveBranch::Middleware, inflection_header: 'Inflect-With'
|
55
|
+
```
|
56
|
+
|
57
|
+
A default inflection can be specified so you don't have to include the `Key-Inflection` header on every request.
|
52
58
|
|
53
59
|
```ruby
|
54
60
|
config.middleware.use OliveBranch::Middleware, inflection: 'camel'
|
@@ -55,6 +55,8 @@ module OliveBranch
|
|
55
55
|
@exclude_response = args[:exclude_response] || Checks.method(:default_exclude)
|
56
56
|
@exclude_params = args[:exclude_params] || Checks.method(:default_exclude)
|
57
57
|
@default_inflection = args[:inflection]
|
58
|
+
@inflection_header = args.fetch(:inflection_header, 'Key-Inflection').gsub(/[^a-z0-9]/i, '_').upcase
|
59
|
+
@inflection_header = "HTTP_#{@inflection_header}" unless @inflection_header.start_with?('HTTP_')
|
58
60
|
end
|
59
61
|
|
60
62
|
def call(env)
|
@@ -100,7 +102,7 @@ module OliveBranch
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def inflection_type(env)
|
103
|
-
env[
|
105
|
+
env[@inflection_header] || @default_inflection
|
104
106
|
end
|
105
107
|
|
106
108
|
def inflection_method(env)
|
data/lib/olive_branch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olive_branch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Fatsi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|