json_schema_tools 0.0.3 → 0.0.4

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.
@@ -42,7 +42,7 @@ module SchemaTools
42
42
  real_class_name = obj.class.name.split('::').last.underscore
43
43
  class_name = opts[:class_name] || real_class_name
44
44
 
45
- return obj if ['array', 'hash'].include? class_name
45
+ return obj if ['Array', 'Hash'].include? class_name
46
46
 
47
47
  data = {}
48
48
  # get schema
@@ -52,16 +52,16 @@ module SchemaTools
52
52
  next if fields && !fields.include?(field)
53
53
  if prop['type'] == 'array'
54
54
  data[field] = [] # always set an empty array
55
- if rel_objects = obj.send( field )
55
+ if obj.respond_to?( field ) && rel_objects = obj.send( field )
56
56
  rel_objects.each do |rel_obj|
57
- data[field] << to_hash_from_schema(rel_obj, version)
57
+ data[field] << from_schema(rel_obj, opts)
58
58
  end
59
59
  end
60
60
  elsif prop['type'] == 'object' # a singular related object
61
61
  data[field] = nil # always set empty val
62
- if rel_obj = obj.send( field )
62
+ if obj.respond_to?( field ) && rel_obj = obj.send( field )
63
63
  #dont nest field to prevent => client=>{client=>{data} }
64
- data[field] = to_hash_from_schema(rel_obj, version)
64
+ data[field] = from_schema(rel_obj, opts)
65
65
  end
66
66
  else # a simple field is only added if the object knows it
67
67
  data[field] = obj.send(field) if obj.respond_to?(field)
@@ -1,3 +1,3 @@
1
1
  module SchemaBuilder
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_schema_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: 1443781473730246135
143
+ hash: 2181020183167996897
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  segments:
151
151
  - 0
152
- hash: 1443781473730246135
152
+ hash: 2181020183167996897
153
153
  requirements: []
154
154
  rubyforge_project:
155
155
  rubygems_version: 1.8.24