l43_open_object 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/l43/open_object/version.rb +1 -1
- data/lib/l43/typed_class/description.rb +2 -2
- data/lib/l43/typed_class/impl_helper.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f7fc44fb3888a0fd0ba528947c0941aed333c9137a3951cf386d9cf417912a7
|
|
4
|
+
data.tar.gz: edd172d163970f148337fbcdab40f2f0d0021eb5fda9f40fdbb17bc3c43caa37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 884418b5c75ca3161d48fcf79a9b0901b3b2fbfdba7ab31cd96f30b35c408866f8bb623d65e629b831c6f374ce958878ca3b3f0ebd2f3c5496905ca862fada68
|
|
7
|
+
data.tar.gz: b46d6021ccd011e69da8cf319d74cb6807aaadeb79779c4262043d0018394bff4e1ec47f819fb0bf01b1a0bae55c109f58c306ca4f3281e4402a41d849db27f6
|
|
@@ -12,8 +12,8 @@ module L43
|
|
|
12
12
|
@__callable_6B9l39xVLR8UnX5U = nil
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def attr(name, default: None, as: None, &blk)
|
|
16
|
-
@__atts_6B9l39xVLR8UnX5U.update(name => OpenStruct.new(default:, type: as, constraint: blk))
|
|
15
|
+
def attr(name, default: None, as: None, nullable: false, &blk)
|
|
16
|
+
@__atts_6B9l39xVLR8UnX5U.update(name => OpenStruct.new(default:, type: as, constraint: blk, nullable:))
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def make_callable(&blk)
|
|
@@ -17,8 +17,10 @@ module L43
|
|
|
17
17
|
raise SpuriousAttribute, "the following attributes have not been defined on this class: #{spurious.inspect}"
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def check_type(type, value)
|
|
20
|
+
def check_type(type, value, nullable:)
|
|
21
21
|
return if None == type
|
|
22
|
+
return if value.nil? && nullable
|
|
23
|
+
|
|
22
24
|
case type
|
|
23
25
|
when Array
|
|
24
26
|
return true unless type.member?(value)
|
|
@@ -28,7 +30,7 @@ module L43
|
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
def check_value(desc, value)
|
|
31
|
-
return :type if check_type(desc.type, value)
|
|
33
|
+
return :type if check_type(desc.type, value, nullable: desc.nullable)
|
|
32
34
|
case desc.constraint
|
|
33
35
|
when nil
|
|
34
36
|
nil
|