jsonapi_compliable 0.5.1 → 0.5.2

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: 363fc9bc08c13030150de69edfaec4bbbbbdb03b
4
- data.tar.gz: c7b39b7e43d39bb165c5eda6ae41e5be72f6532d
3
+ metadata.gz: 58d8e742552f8d3c559e5717fd4e282846e4d904
4
+ data.tar.gz: f297e2bf808e4a22596ac9fdc54e0350f6a5e132
5
5
  SHA512:
6
- metadata.gz: b4284c0e7b12b594985925c4c30f74c911c526cfa6531ed0c5990069d9f8e148cde3f4162a89e0e5f5ad177c1ac9bd042daf9228c72e963efd62920d1b7fa4e4
7
- data.tar.gz: 2b90de831bb4d5678bf996bfc1806f55ac9b6f99f4167d9e3b1de9c3ee9df96de068c2a53f5109cd88b7c5de1f23d5a723d0f4f7732879929532fed7e073ac25
6
+ metadata.gz: 42c2dff29d06844d41e3c1042065d33d627e41d4a84231e947d77ca416b63317c9dd5e97fa94da9327197c918c5675a53293257d4bbe53206ec7de35d98cf743
7
+ data.tar.gz: bd862e16092f6e89f6652fc1c0dd814f0f30095329678776c9eb3045336b164a87360467b7f53d92b4fc5142f1aee3475e4a8bd7bdc1547373ae1cfb62277116
@@ -15,10 +15,6 @@ module JsonapiCompliable
15
15
  scope.page(current_page).per(per_page)
16
16
  end
17
17
 
18
- def sideload(scope, includes)
19
- scope.includes(includes)
20
- end
21
-
22
18
  def count(scope, attr)
23
19
  scope.count
24
20
  end
@@ -88,6 +88,8 @@ module JsonapiCompliable
88
88
 
89
89
  # Legacy
90
90
  def force_includes?
91
+ return false unless defined?(Rails)
92
+
91
93
  %w(PUT PATCH POST).include?(request.method) and
92
94
  raw_params.try(:[], :data).try(:[], :relationships).present?
93
95
  end
@@ -112,7 +112,7 @@ module JsonapiCompliable
112
112
  end
113
113
 
114
114
  def deserialize_jsonapi!
115
- self.raw_params = self.params.deep_dup
115
+ self.raw_params = Util::Hash.deep_dup(self.params)
116
116
 
117
117
  if defined?(::Rails) && (is_a?(ActionController::Base) || (defined?(ActionController::API) && is_a?(ActionController::API)))
118
118
  hash = params.to_unsafe_h
@@ -31,7 +31,7 @@ module JsonapiCompliable
31
31
  end
32
32
 
33
33
  def self.inherited(klass)
34
- klass.config = self.config.deep_dup
34
+ klass.config = Util::Hash.deep_dup(self.config)
35
35
  end
36
36
 
37
37
  def self.sideloading
@@ -112,11 +112,12 @@ module JsonapiCompliable
112
112
  end
113
113
 
114
114
  def copy
115
- self.class.new(@config.deep_dup)
115
+ self.class.new(@config)
116
116
  end
117
117
 
118
118
  def initialize(config = nil)
119
- config = config || self.class.config.deep_dup
119
+ config = config || self.class.config
120
+ config = Util::Hash.deep_dup(config)
120
121
  set_config(config)
121
122
  end
122
123
 
@@ -24,7 +24,7 @@ module JsonapiCompliable
24
24
  else
25
25
  resolved = @object
26
26
  # TODO - configurable resolve function
27
- resolved = @object.to_a if @object.is_a?(ActiveRecord::Relation)
27
+ resolved = @object.to_a if defined?(ActiveRecord) && @object.is_a?(ActiveRecord::Relation)
28
28
  sideload(resolved, query_hash[:include]) if query_hash[:include]
29
29
  resolved
30
30
  end
@@ -9,6 +9,20 @@ module JsonapiCompliable
9
9
 
10
10
  collection
11
11
  end
12
+
13
+ def self.deep_dup(hash)
14
+ if hash.respond_to?(:deep_dup)
15
+ hash.deep_dup
16
+ else
17
+ {}.tap do |duped|
18
+ hash.each_pair do |key, value|
19
+ value = deep_dup(value) if value.is_a?(Hash)
20
+ value = value.dup if value && value.respond_to?(:dup) && ![Symbol, Fixnum].include?(value.class)
21
+ duped[key] = value
22
+ end
23
+ end
24
+ end
25
+ end
12
26
  end
13
27
  end
14
28
  end
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-02-08 00:00:00.000000000 Z
12
+ date: 2017-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable