ializer 0.10.1 → 0.13.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/fix_num_de_ser.rb +1 -1
- data/lib/ializer/version.rb +1 -1
- data/lib/ser/ializer/field.rb +2 -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: 8576d59eb12dbcbb21750ff9d90e0d3de7f3e1e9df46b70c74924692ecfc22fc
|
4
|
+
data.tar.gz: 78cfd59cc6b962793c4f1a5413dc2667a00bd15372243e34e035831f88d898b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 556be5da20a96c4a6d5221e51661321d9c1a79336b5917bf61323262ddd65f56b4f21e134c20ccd36d321ea71fb70399ae1a7f94c913d81401c0bc6e3e5758f7
|
7
|
+
data.tar.gz: 7144f7808f6c8a92caa1c3241466f97a8dbb557725e5fc0a0f8d43d4b88e5b0edff648838bfe2c363b9d7f3b2fd2614970a3ba75f596d018f84eea367a857d02
|
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
data/lib/ser/ializer/field.rb
CHANGED
@@ -11,7 +11,7 @@ module Ser
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
attr_reader :name, :setter, :key, :deser, :model_class, :if_condition, :block, :description
|
14
|
+
attr_reader :name, :setter, :key, :deser, :model_class, :if_condition, :block, :description, :documentation
|
15
15
|
|
16
16
|
def initialize(name, options, config, &block)
|
17
17
|
@name = name
|
@@ -21,6 +21,7 @@ module Ser
|
|
21
21
|
@if_condition = options[:if]
|
22
22
|
@model_class = options[:model_class]
|
23
23
|
@description = options[:desc]
|
24
|
+
@documentation = options[:documentation]
|
24
25
|
@block = block
|
25
26
|
end
|
26
27
|
|
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.13.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.15
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: Simple (de)serializers for Ruby objects
|