firm 0.9.2 → 0.9.3

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
  SHA256:
3
- metadata.gz: 2f6498bd122a2588336365f1120c424cfdf65fd5e05d87b4c5b3175c92d72965
4
- data.tar.gz: bbf7816402e9f0c1b977dd47cfefc6b600e389c6e3710436a8d62fc9eee42a3d
3
+ metadata.gz: 5c1c7b999e2db422d608d8aaf8e28a9bace6824640f50a8e5dabb30e2ca89a36
4
+ data.tar.gz: a16d62247a09cc2e1d8b3c4d2a990ffefb7b48c18f6f1d8f27e12c770ff103eb
5
5
  SHA512:
6
- metadata.gz: 0fcc10bf8e5d448f02482fe453fc20433ca26781d08c55a0dba0e0b0947e17aae91d4f97d45c858ae5f73b170c37cb0c646caad3904d573745b8737ac6e61aac
7
- data.tar.gz: 7bc179e75ea98e4505156d3ff59d53f7d07931c0d24b40e4adb127ae82be1bcf205a19b0811bebd557f4c519dd507f8802c8e7f25c0ed60ef9d6c75f2fee30ef
6
+ metadata.gz: 6c45a0bc530a143ad8b37de7e00f6fdd4a2af91ffb52b18ce86f91ffac390ea05825d58b042e29361a96fd762be58d210d141bdb88d9748c3232e7c30232b8cc
7
+ data.tar.gz: 939fe265f4f55f1255851e5f246b73ca416c6649af2ffcdad6aa8fb63341289ef64c71678bc02a7372c66acd6a91a26111ebc049d2a571b5f3f189f7010d3fb2
@@ -148,20 +148,20 @@ module FIRM
148
148
  def json_create(object)
149
149
  data = object['data']
150
150
  # deserializing (anchor) object or alias
151
- if data.has_key?('*id')
152
- if Serializable::Aliasing.restored?(self, data['*id'])
151
+ if object.has_key?('*id')
152
+ if Serializable::Aliasing.restored?(self, object['*id'])
153
153
  # resolving an already restored anchor for this alias
154
- Serializable::Aliasing.resolve_anchor(self, data['*id'])
154
+ Serializable::Aliasing.resolve_anchor(self, object['*id'])
155
155
  else
156
156
  # in case of cyclic references JSON will restore aliases before the anchors
157
157
  # so in this case we allocate an instance here and register it as
158
158
  # the anchor; when the anchor is restored it will re-use this instance to initialize & restore
159
159
  # the properties
160
- Serializable::Aliasing.restore_anchor(data['*id'], self.allocate)
160
+ Serializable::Aliasing.restore_anchor(object['*id'], self.allocate)
161
161
  end
162
162
  else
163
- instance = if data.has_key?('&id')
164
- anchor_id = data.delete('&id') # extract anchor id
163
+ instance = if object.has_key?('&id')
164
+ anchor_id = object['&id'] # extract anchor id
165
165
  if Serializable::Aliasing.restored?(self, anchor_id)
166
166
  # in case of cyclic references an alias will already have restored the anchor instance
167
167
  # (default constructed); retrieve that instance here for deserialization of properties
@@ -192,19 +192,14 @@ module FIRM
192
192
  anchor_data = Serializable::Aliasing.get_anchor_data(self)
193
193
  # retroactively insert the anchor in the anchored instance's serialization data
194
194
  anchor_data['&id'] = anchor unless anchor_data.has_key?('&id')
195
- json_data["data"] = {
196
- '*id' => anchor
197
- }
195
+ json_data['*id'] = anchor
198
196
  else
199
197
  # register anchor object **before** serializing properties to properly handle cycling (bidirectional
200
198
  # references)
201
- if defined? JRUBY_VERSION
202
- # JRuby has a problem modifying a hash while iterating it so we create a new copy here which we
203
- # merge with the original because that may be updated with an anchor id
204
- json_data['data'] = for_serialize(Serializable::Aliasing.register_anchor_object(self, {}))
205
- json_data['data'].merge!(json_data['data'].transform_values { |v| v.respond_to?(:as_json) ? v.as_json : v })
206
- else
207
- json_data['data'] = for_serialize(Serializable::Aliasing.register_anchor_object(self, {}))
199
+ Serializable::Aliasing.register_anchor_object(self, json_data)
200
+ data = for_serialize({})
201
+ unless data.empty?
202
+ json_data['data'] = data
208
203
  json_data['data'].transform_values! { |v| v.respond_to?(:as_json) ? v.as_json : v }
209
204
  end
210
205
  end
data/lib/firm/version.rb CHANGED
@@ -4,6 +4,6 @@
4
4
  module FIRM
5
5
 
6
6
  # FIRM version
7
- VERSION = "0.9.2"
7
+ VERSION = "0.9.3"
8
8
 
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Corino