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 +4 -4
- data/README.md +12 -0
- data/lib/de/ser/ializer.rb +9 -1
- data/lib/ializer/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 046653c46495303f818fed936f4017c82a8c951882ab704630b2eeb0f1ec0729
|
4
|
+
data.tar.gz: 71f59e15ab4fb65620a9b589e2f8b6711b0d3e16f9e3b39e86492d200c5a5224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/de/ser/ializer.rb
CHANGED
@@ -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
|
-
|
70
|
+
public_send(field.setter, object, parsed_value)
|
63
71
|
end
|
64
72
|
|
65
73
|
def ostruct?(model_class)
|
data/lib/ializer/version.rb
CHANGED
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.
|
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-
|
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.
|
196
|
+
rubygems_version: 3.2.22
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Simple (de)serializers for Ruby objects
|