introspective_grape 0.3.0 → 0.3.1
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 169097ef08e0a724df757dd60c0b47341999bd59
|
4
|
+
data.tar.gz: 6be10a74972810ca030c0a518893656b599369be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cdc1e63fa9169dfbb90eb275f8dbeac342bdecab7bc324733b8194d47d720a4ffbc68693499a94652f865dd267817cdb769c8a663b09534a635c135321bbc10
|
7
|
+
data.tar.gz: c5be58cfc13ee4be45df0a349d6712b585cb9919f64a925c60b97d3a1a97cbceeaf6690f9faddd6572b82c76bf3f51b728cdb17af8e0ea94f257c335229ca4c2
|
@@ -1,15 +1,17 @@
|
|
1
1
|
# Add a formatter to grape that converts all snake case hash keys from ruby to camel case.
|
2
2
|
require 'camel_snake_keys'
|
3
|
+
require 'grape/formatter/json'
|
3
4
|
module IntrospectiveGrape
|
4
5
|
module Formatter
|
5
6
|
module CamelJson
|
6
7
|
def self.call(object, _env)
|
7
|
-
if object.respond_to?(:to_json)
|
8
|
-
JSON.parse(object.to_json).with_camel_keys
|
9
|
-
|
10
|
-
MultiJson.dump(object).with_camel_keys.to_json
|
8
|
+
if object.respond_to?(:to_json) && !object.respond_to?(:with_camel_keys) &&
|
9
|
+
(parsed_object = JSON.parse(object.to_json)).respond_to?(:with_camel_keys)
|
10
|
+
object = parsed_object
|
11
11
|
end
|
12
|
+
object = object.with_camel_keys if object.respond_to?(:with_camel_keys)
|
13
|
+
Grape::Formatter::Json.call(object, _env)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
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.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Buermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|