ializer 0.10.2 → 0.12.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: c00a69cfd664143494407679066729ac9251cbf300d6168d1a6fa43dec1966c2
4
- data.tar.gz: 0dc7bb3dcc2354ed6faf3d677297194aa730ea5a5f72547796eb786b09972722
3
+ metadata.gz: 046653c46495303f818fed936f4017c82a8c951882ab704630b2eeb0f1ec0729
4
+ data.tar.gz: 71f59e15ab4fb65620a9b589e2f8b6711b0d3e16f9e3b39e86492d200c5a5224
5
5
  SHA512:
6
- metadata.gz: 7ccbcefea07e0df88dd2114fa53df0e98e27da13a2eaaeb54fff01663055f8a6304c9d39f0c691318cd5a54d7abaef6c9bb48f7b5068dfe8a6c33de0bcde67d5
7
- data.tar.gz: d7cb6b38f6c6408131552a5dc93aa48bd70582ed6a0af1720cb326323bdf30db29b65e01d5b69f824f16f578a8961764371191eaf40ab9bcaa8cbf284655b875
6
+ metadata.gz: 14305639f9d74861e2e5013fb9dfe22bb8e6ba82c6d6cbf52d8c7f2f753205f04bdccf34f99939213df70f71b1db002841fcc7efe01c8ac8cc5cd43a2c40628e
7
+ data.tar.gz: 6cab0473cd8e107c8be3b63a1aade57b69f2464304e48c7ba73f43f559ee6c0bbcf97fcaec1b9aeca66bf15fe4bb1c77cac208b4725a5f421cfb8adcf8391d14
data/README.md CHANGED
@@ -427,6 +427,18 @@ class Customer < De::Ser::Ializer
427
427
  end
428
428
  ```
429
429
 
430
+ Setters can also be overridden:
431
+
432
+ ```ruby
433
+ class Customer < De::Ser::Ializer
434
+ string :name
435
+
436
+ def self.name=(object, value)
437
+ object.name = value.delete_suffix('Part 2')
438
+ end
439
+ end
440
+ ```
441
+
430
442
  Attributes can also use a different name by passing the original method or accessor with a proc shortcut:
431
443
 
432
444
  ```ruby
@@ -52,6 +52,14 @@ module De
52
52
 
53
53
  private
54
54
 
55
+ def add_attribute(field)
56
+ super
57
+
58
+ define_singleton_method field.setter do |object, parsed_value|
59
+ object.public_send(field.setter, parsed_value)
60
+ end
61
+ end
62
+
55
63
  def parse_field(object, field, value)
56
64
  return if value.nil?
57
65
 
@@ -59,7 +67,7 @@ module De
59
67
 
60
68
  return if parsed_value.nil?
61
69
 
62
- object.public_send(field.setter, parsed_value)
70
+ public_send(field.setter, object, parsed_value)
63
71
  end
64
72
 
65
73
  def ostruct?(model_class)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ializer
4
- VERSION = '0.10.2'
4
+ VERSION = '0.12.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ializer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Steinberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  requirements: []
196
- rubygems_version: 3.0.9
196
+ rubygems_version: 3.2.22
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Simple (de)serializers for Ruby objects