rjr 0.16.5 → 0.16.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/rjr/common.rb +18 -12
  2. metadata +1 -1
data/lib/rjr/common.rb CHANGED
@@ -188,7 +188,7 @@ class Class
188
188
  end
189
189
 
190
190
  module RJR
191
- def self.validate_json_class(jc)
191
+ def self.invalid_json_class?(jc)
192
192
  Class.whitelist_json_classes ||= false
193
193
 
194
194
  Class.whitelist_json_classes ?
@@ -209,29 +209,35 @@ module RJR
209
209
 
210
210
  def self.validate_json_hash(jh)
211
211
  jh.each { |k,v|
212
- if k == ::JSON.create_id &&
213
- validate_json_class(v)
212
+ if k == ::JSON.create_id && invalid_json_class?(v)
214
213
  raise ArgumentError, "can't create json class #{v}"
215
214
  elsif v.is_a?(Array)
216
- v.each { |vi|
217
- if vi.is_a?(Hash)
218
- validate_json_hash(vi)
219
- end
220
- }
215
+ validate_json_array(v)
221
216
  elsif v.is_a?(Hash)
222
217
  validate_json_hash(v)
223
218
  end
224
219
  }
225
220
  end
221
+
222
+ def self.validate_json_array(ja)
223
+ ja.each { |jai|
224
+ if jai.is_a?(Array)
225
+ validate_json_array(jai)
226
+ elsif jai.is_a?(Hash)
227
+ validate_json_hash(jai)
228
+ end
229
+ }
230
+ end
226
231
 
227
232
  def self.parse_json(js)
228
233
  jp = ::JSON.parse js, :create_additions => false
229
234
  if jp.is_a?(Array)
230
- jp.each { |jpi| parse_json(jpi.to_json) }
231
- elsif !jp.is_a?(Hash)
232
- return
235
+ validate_json_array(jp)
236
+ elsif jp.is_a?(Hash)
237
+ validate_json_hash(jp)
238
+ else
239
+ return jp
233
240
  end
234
- validate_json_hash(jp)
235
241
  ::JSON.parse js, :create_additions => true
236
242
  end
237
243
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.5
4
+ version: 0.16.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: