simply_serializable 1.1.0 → 1.2.0

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: bd5e5fe82b38894f4b90439928e4de8383e8f4fac49bb152d966dd6f0f309cd2
4
- data.tar.gz: 258bebc2ed9a8a676ca6bf2c847360f9655a61de660cea0b08011cddfc82d3d3
3
+ metadata.gz: df935792cdc1ffb0a64da0a012012c8ab5f20babe717dc2d25234b896ec4bd7e
4
+ data.tar.gz: f3d687f5830508b6b764173340d3091d84fadacc34bf6e487242090ac1fe8bed
5
5
  SHA512:
6
- metadata.gz: 40aade8c05d4e355e7fdf59ccdae2848d6a4cbddf9bcabc895669ca72e288a6f69d4006014b924c9d4b92912eb53989815c72e092ec83978f49338d39e7373d3
7
- data.tar.gz: 9b280e7b8cf8694035eff62d5994c2535523963110bce882c08feb6447c0b542f1aa2e32c5d3f1571bea3382d90b3fb9fb45e77e3017dcaa23298f500e31ed74
6
+ metadata.gz: baca71832e1bbc1106b1a179edc1320fefda102cce0934beb7c2eec9680a44fe9d67abbb10d25ab39feadd7f3261a3e1b246e5b74204cc912406d51322d93579
7
+ data.tar.gz: 774d38c38f1d4d8ed477106001ac17a2e459a573ea6239274be5c4676882e7d369088e725e1f042e254b33bdbb41a9c173d7e3c0ed5efc0739f25fab3d691ca6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simply_serializable (1.1.0)
4
+ simply_serializable (1.2.0)
5
5
  fingerprintable (>= 1.2.1)
6
6
 
7
7
  GEM
@@ -8,17 +8,24 @@ module SimplySerializable
8
8
  super(subclass)
9
9
  end
10
10
 
11
- def serialize(attributes: [], except: [], only: [])
11
+ def serialize(attributes: [], except: nil, only: nil)
12
12
  serializable_config[:attributes] = serializable_config[:attributes] |= attributes
13
- serializable_config[:except] = serializable_config[:except] |= except
14
- serializable_config[:only] = serializable_config[:only] |= only
13
+ unless except.nil?
14
+ serializable_config[:except] ||= []
15
+ serializable_config[:except] = serializable_config[:except] |= except
16
+ end
17
+
18
+ unless only.nil?
19
+ serializable_config[:only] ||= []
20
+ serializable_config[:only] = serializable_config[:only] |= only
21
+ end
15
22
  end
16
23
 
17
24
  def serializable_config
18
25
  @serializable_config ||= {
19
26
  attributes: [],
20
- except: [],
21
- only: []
27
+ except: nil,
28
+ only: nil
22
29
  }
23
30
  end
24
31
  end
@@ -10,17 +10,17 @@ module SimplySerializable
10
10
  def initialize(
11
11
  attributes: [],
12
12
  cache: {},
13
- except: [],
13
+ except: nil,
14
14
  include_readable_instance_variables: true,
15
15
  method_prefix: :serialize,
16
16
  object:,
17
- only: []
17
+ only: nil
18
18
  )
19
19
  @object = object
20
20
  @attributes = attributes
21
21
  @include_readable_instance_variables = include_readable_instance_variables
22
- @except = except.map(&:to_sym)
23
- @only = only.map(&:to_sym)
22
+ @except = except&.map(&:to_sym)
23
+ @only = only&.map(&:to_sym)
24
24
  @method_prefix = method_prefix
25
25
  @cache = cache
26
26
  @cache[cache_key] = nil
@@ -91,12 +91,12 @@ module SimplySerializable
91
91
  end
92
92
 
93
93
  def populate_attributes
94
- raise 'You cannot pass only and except values. Please choose one.' if only.any? && except.any?
94
+ raise 'You cannot pass only and except values. Please choose one.' if !only.nil? && !except.nil?
95
95
 
96
96
  @attributes |= instance_vars_with_readers if @include_readable_instance_variables
97
97
 
98
- @attributes = attributes & only if only.any?
99
- @attributes = attributes - except if except.any?
98
+ @attributes = only unless only.nil?
99
+ @attributes = attributes - except unless except.nil?
100
100
  attributes
101
101
  end
102
102
 
@@ -1,3 +1,3 @@
1
1
  module SimplySerializable
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_serializable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Jackson