panko_serializer 0.1.9 → 0.1.10

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: 9c6bed38967e51bd9b7902aa9b98378c47ed947e
4
- data.tar.gz: a538bbe197fabf3220485e05c886a47d6cf22713
3
+ metadata.gz: 21cd55b904edc40658adf9f43695d89e8962b2c5
4
+ data.tar.gz: 664554f19ac39bca5e995e3fce1d50d2293e7ae2
5
5
  SHA512:
6
- metadata.gz: 16fb0300a61dfd66e5b364640846dd1bdb7944a707e44e904f043b332b0ab700d878de100f5828577fdc1acc1b7e0247411b99a770ca9f3aa0b7e90b6acd79d5
7
- data.tar.gz: ec5ac08ac0c6b8f20c714d3cd2079667ef45bd0f332df9d3a2eb527221c0e147e8cc183ae972d9b7b8bff2518b6a384ed8df08e8874535e4f35b2db23f2f9c53
6
+ metadata.gz: e4a4c7bd6d5e437ed52bb617dfa36b4970cd2274952df2870858f470bec00db243dd9fe1fd1b8bb163f42d51463ba41dce68f7a5d52a80803f0aa9d4dd0f9177
7
+ data.tar.gz: d047bfc815bd8e092f0dceee0e2815a38e04d082157cf4fb873215e61a0f80a17e82ef793ce0665b22707da65779048bd6f0f66e6c465d82754b8d8890725303
@@ -13,7 +13,7 @@ void write_value(VALUE str_writer,
13
13
  VALUE key,
14
14
  VALUE value,
15
15
  VALUE type_metadata) {
16
- if (type_metadata != Qnil) {
16
+ if (type_metadata != Qnil && value != Qnil) {
17
17
  value = type_cast(type_metadata, value);
18
18
  }
19
19
 
@@ -52,9 +52,6 @@ SerializationDescriptor sd_read(VALUE descriptor) {
52
52
  }
53
53
 
54
54
  VALUE sd_build_serializer(SerializationDescriptor sd) {
55
- // We build the serializer and cache it on demand,
56
- // because of our cache - we lock and create descriptor, while inside
57
- // a descriptor we can't create another descriptor - deadlock.
58
55
  if (sd->serializer == Qnil) {
59
56
  VALUE args[0];
60
57
  sd->serializer = rb_class_new_instance(0, args, sd->serializer_type);
@@ -65,7 +62,9 @@ VALUE sd_build_serializer(SerializationDescriptor sd) {
65
62
 
66
63
  void sd_apply_serializer_config(VALUE serializer, VALUE object, VALUE context) {
67
64
  rb_ivar_set(serializer, object_id, object);
68
- rb_ivar_set(serializer, context_id, context);
65
+ if(context != Qnil && context != Qundef) {
66
+ rb_ivar_set(serializer, context_id, context);
67
+ }
69
68
  }
70
69
 
71
70
  VALUE serialization_descriptor_fields_set(VALUE self, VALUE fields) {
@@ -241,6 +241,10 @@ VALUE cast_date_time_type(VALUE value) {
241
241
  }
242
242
 
243
243
  VALUE type_cast(VALUE type_metadata, VALUE value) {
244
+ if(value == Qnil || value == Qundef) {
245
+ return value;
246
+ }
247
+
244
248
  cache_type_lookup();
245
249
 
246
250
  VALUE type_klass, typeCastedValue;
@@ -15,7 +15,7 @@ module Panko
15
15
  }
16
16
 
17
17
  @descriptor = Panko::SerializationDescriptor.build(@each_serializer, serializer_options)
18
- @context = options.fetch(:context, nil)
18
+ @context = options[:context]
19
19
  end
20
20
 
21
21
  def to_json
data/lib/panko/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Panko
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panko_serializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosi Attias
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-07 00:00:00.000000000 Z
11
+ date: 2017-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler