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: cb071dc16f5b81676e9c1f8472729d13d6ac51b5
4
- data.tar.gz: ff807faad54a81270717f30e7c46320f56147bbb
3
+ metadata.gz: 169097ef08e0a724df757dd60c0b47341999bd59
4
+ data.tar.gz: 6be10a74972810ca030c0a518893656b599369be
5
5
  SHA512:
6
- metadata.gz: fcb4c96419246d601ebcc8c96ea5b1bad2ca4cdb44ec5e3fc2c89ce72a59b53778b21258160cde463c23bf7cb468fbec833cb2337c24e8b754a6530a7049ca21
7
- data.tar.gz: fa6897a8637f5e58b2ace975324f4c186257046bb340774d11851268b0bd78cd1bc432b8b92eff4fcf6065cb74f1bec7e310085d4a33dec7731079fbc4f2327b
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.to_json
9
- else
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
@@ -1,3 +1,3 @@
1
1
  module IntrospectiveGrape
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".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.0
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-22 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails