castkit 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6073763678bdbc5315b5ade9dd3488159932de8d4235f11e02b6a6d2fe7a505d
4
- data.tar.gz: 3e379f55d003101c99e8ace3e826094d69769925c3296d56f1fe126378f9fea8
3
+ metadata.gz: 95050d3dd1d35789f00934058e7170ca3f83488bc5fd09bc0925541b5a4064dc
4
+ data.tar.gz: a5696ecf5e038e4ebc5a98a6bed7b450b79cee9f5b785dd43b284d39900bbbde
5
5
  SHA512:
6
- metadata.gz: 8374ef2c3a57f7c0c0730c1be9df5cb1ea1ab59fb4653a9120306e272da09058b777a3f36c1477c8c9e3e254157ea06b986e5b89243a6ee25a355b7844c2fc13
7
- data.tar.gz: cc690abd00f8df3cefbc754060f09d4cf77c3e1df1f5bf5dd0ddf77ae3efde0cea995949e2c8da9e7c8b51e9a943f077b854e60d2309a7044a3109a8acc11345
6
+ metadata.gz: a645ee089081292c94ad303f758ea8f9f106543c4f0a4705124d9bcdaae9496d8d1f13205965bd356f65efd67e47cb61b750cf5621cd6d9317b54e87b1ea3c76
7
+ data.tar.gz: 9c850e2e1a69817fa5ed91593057385779e241d4215474455eed201c6b8c3eada2a3855cbae9a22feb512b9682de739ee07c68b9f40da14d11a180e3f4c8e18d
data/.rspec_status CHANGED
@@ -1,205 +1,216 @@
1
1
  example_id | status | run_time |
2
2
  --------------------------------------------------------------------- | ------ | --------------- |
3
- ./spec/castkit/attribute_extensions/access_spec.rb[1:1:1] | passed | 0.00294 seconds |
4
- ./spec/castkit/attribute_extensions/access_spec.rb[1:1:2:1] | passed | 0.00005 seconds |
3
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:1:1] | passed | 0.00053 seconds |
4
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:1:2:1] | passed | 0.00007 seconds |
5
5
  ./spec/castkit/attribute_extensions/access_spec.rb[1:1:3:1] | passed | 0.00004 seconds |
6
6
  ./spec/castkit/attribute_extensions/access_spec.rb[1:1:4:1] | passed | 0.00004 seconds |
7
- ./spec/castkit/attribute_extensions/access_spec.rb[1:2:1:1] | passed | 0.00088 seconds |
8
- ./spec/castkit/attribute_extensions/access_spec.rb[1:2:2:1] | passed | 0.00006 seconds |
9
- ./spec/castkit/attribute_extensions/access_spec.rb[1:2:3:1] | passed | 0.00004 seconds |
7
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:2:1:1] | passed | 0.00122 seconds |
8
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:2:2:1] | passed | 0.00008 seconds |
9
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:2:3:1] | passed | 0.00005 seconds |
10
10
  ./spec/castkit/attribute_extensions/access_spec.rb[1:3:1] | passed | 0.00004 seconds |
11
- ./spec/castkit/attribute_extensions/access_spec.rb[1:3:2] | passed | 0.00003 seconds |
12
- ./spec/castkit/attribute_extensions/access_spec.rb[1:3:3] | passed | 0.00003 seconds |
13
- ./spec/castkit/attribute_extensions/access_spec.rb[1:3:4] | passed | 0.00003 seconds |
11
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:3:2] | passed | 0.00004 seconds |
12
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:3:3] | passed | 0.00004 seconds |
13
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:3:4] | passed | 0.00004 seconds |
14
14
  ./spec/castkit/attribute_extensions/access_spec.rb[1:3:5] | passed | 0.00003 seconds |
15
- ./spec/castkit/attribute_extensions/access_spec.rb[1:4:1:1] | passed | 0.00004 seconds |
16
- ./spec/castkit/attribute_extensions/access_spec.rb[1:4:2:1] | passed | 0.0001 seconds |
17
- ./spec/castkit/attribute_extensions/access_spec.rb[1:4:3:1] | passed | 0.00004 seconds |
18
- ./spec/castkit/attribute_extensions/access_spec.rb[1:5:1] | passed | 0.00003 seconds |
19
- ./spec/castkit/attribute_extensions/access_spec.rb[1:5:2] | passed | 0.00003 seconds |
20
- ./spec/castkit/attribute_extensions/access_spec.rb[1:5:3] | passed | 0.00003 seconds |
15
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:4:1:1] | passed | 0.00006 seconds |
16
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:4:2:1] | passed | 0.00006 seconds |
17
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:4:3:1] | passed | 0.00012 seconds |
18
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:5:1] | passed | 0.00004 seconds |
19
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:5:2] | passed | 0.00005 seconds |
20
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:5:3] | passed | 0.00004 seconds |
21
21
  ./spec/castkit/attribute_extensions/access_spec.rb[1:6:1:1] | passed | 0.00004 seconds |
22
- ./spec/castkit/attribute_extensions/access_spec.rb[1:6:2:1] | passed | 0.00003 seconds |
23
- ./spec/castkit/attribute_extensions/access_spec.rb[1:6:3:1] | passed | 0.00003 seconds |
24
- ./spec/castkit/attribute_extensions/access_spec.rb[1:7:1:1] | passed | 0.00003 seconds |
22
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:6:2:1] | passed | 0.00005 seconds |
23
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:6:3:1] | passed | 0.00004 seconds |
24
+ ./spec/castkit/attribute_extensions/access_spec.rb[1:7:1:1] | passed | 0.00004 seconds |
25
25
  ./spec/castkit/attribute_extensions/access_spec.rb[1:7:2:1] | passed | 0.00004 seconds |
26
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:1:1] | passed | 0.00005 seconds |
27
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:1] | passed | 0.0036 seconds |
28
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:2] | passed | 0.00015 seconds |
29
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:3] | passed | 0.00061 seconds |
30
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:3:1] | passed | 0.00013 seconds |
31
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:4:1] | passed | 0.00007 seconds |
26
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:1:1] | passed | 0.00006 seconds |
27
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:1] | passed | 0.00421 seconds |
28
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:2] | passed | 0.00023 seconds |
29
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:2:3] | passed | 0.00096 seconds |
30
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:3:1] | passed | 0.00021 seconds |
31
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:4:1] | passed | 0.0001 seconds |
32
32
  ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:5:1] | passed | 0.00006 seconds |
33
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:6:1] | passed | 0.00011 seconds |
33
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:6:1] | passed | 0.00015 seconds |
34
34
  ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:7:1] | passed | 0.00005 seconds |
35
35
  ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:8:1] | passed | 0.00005 seconds |
36
36
  ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:9:1] | passed | 0.00004 seconds |
37
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:1] | passed | 0.00004 seconds |
38
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:2] | passed | 0.00005 seconds |
39
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:3] | passed | 0.00005 seconds |
40
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:11:1] | passed | 0.00014 seconds |
41
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:12:1] | passed | 0.00045 seconds |
42
- ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:13:1] | passed | 0.00007 seconds |
43
- ./spec/castkit/attribute_extensions/options_spec.rb[1:1:1:1] | passed | 0.00004 seconds |
44
- ./spec/castkit/attribute_extensions/options_spec.rb[1:1:2:1] | passed | 0.00004 seconds |
45
- ./spec/castkit/attribute_extensions/options_spec.rb[1:2:1:1] | passed | 0.00004 seconds |
46
- ./spec/castkit/attribute_extensions/options_spec.rb[1:2:2:1] | passed | 0.00004 seconds |
37
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:1] | passed | 0.00005 seconds |
38
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:2] | passed | 0.00004 seconds |
39
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:10:3] | passed | 0.00007 seconds |
40
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:11:1] | passed | 0.00015 seconds |
41
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:12:1] | passed | 0.00065 seconds |
42
+ ./spec/castkit/attribute_extensions/casting_spec.rb[1:1:13:1] | passed | 0.00012 seconds |
43
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:1:1:1] | passed | 0.00008 seconds |
44
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:1:2:1] | passed | 0.00179 seconds |
45
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:2:1:1] | passed | 0.00006 seconds |
46
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:2:2:1] | passed | 0.00005 seconds |
47
47
  ./spec/castkit/attribute_extensions/options_spec.rb[1:3:1:1] | passed | 0.00005 seconds |
48
48
  ./spec/castkit/attribute_extensions/options_spec.rb[1:3:2:1] | passed | 0.00005 seconds |
49
- ./spec/castkit/attribute_extensions/options_spec.rb[1:3:3:1] | passed | 0.00005 seconds |
50
- ./spec/castkit/attribute_extensions/options_spec.rb[1:4:1] | passed | 0.00004 seconds |
49
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:3:3:1] | passed | 0.00004 seconds |
50
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:4:1] | passed | 0.00005 seconds |
51
51
  ./spec/castkit/attribute_extensions/options_spec.rb[1:5:1] | passed | 0.00004 seconds |
52
52
  ./spec/castkit/attribute_extensions/options_spec.rb[1:5:2:1] | passed | 0.00004 seconds |
53
- ./spec/castkit/attribute_extensions/options_spec.rb[1:6:1] | passed | 0.00004 seconds |
53
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:6:1] | passed | 0.00006 seconds |
54
54
  ./spec/castkit/attribute_extensions/options_spec.rb[1:7:1] | passed | 0.00004 seconds |
55
- ./spec/castkit/attribute_extensions/options_spec.rb[1:7:2:1] | passed | 0.00004 seconds |
56
- ./spec/castkit/attribute_extensions/options_spec.rb[1:8:1] | passed | 0.00004 seconds |
55
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:7:2:1] | passed | 0.00005 seconds |
56
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:8:1] | passed | 0.00009 seconds |
57
57
  ./spec/castkit/attribute_extensions/options_spec.rb[1:8:2:1] | passed | 0.00004 seconds |
58
- ./spec/castkit/attribute_extensions/options_spec.rb[1:9:1:1] | passed | 0.00004 seconds |
59
- ./spec/castkit/attribute_extensions/options_spec.rb[1:9:2:1] | passed | 0.00004 seconds |
60
- ./spec/castkit/attribute_extensions/options_spec.rb[1:9:3:1] | passed | 0.00008 seconds |
61
- ./spec/castkit/attribute_extensions/options_spec.rb[1:10:1:1] | passed | 0.00004 seconds |
58
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:9:1:1] | passed | 0.00005 seconds |
59
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:9:2:1] | passed | 0.00005 seconds |
60
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:9:3:1] | passed | 0.00004 seconds |
61
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:10:1:1] | passed | 0.00005 seconds |
62
62
  ./spec/castkit/attribute_extensions/options_spec.rb[1:10:2:1] | passed | 0.00004 seconds |
63
63
  ./spec/castkit/attribute_extensions/options_spec.rb[1:11:1:1] | passed | 0.00004 seconds |
64
64
  ./spec/castkit/attribute_extensions/options_spec.rb[1:11:2:1] | passed | 0.00004 seconds |
65
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:12:1:1] | passed | 0.00004 seconds |
66
+ ./spec/castkit/attribute_extensions/options_spec.rb[1:12:2:1] | passed | 0.00004 seconds |
65
67
  ./spec/castkit/attribute_extensions/serialization_spec.rb[1:1:1:1] | passed | 0.00006 seconds |
66
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:1:2:1] | passed | 0.00006 seconds |
67
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:1:3:1] | passed | 0.00004 seconds |
68
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:1:2:1] | passed | 0.00011 seconds |
69
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:1:3:1] | passed | 0.00005 seconds |
68
70
  ./spec/castkit/attribute_extensions/serialization_spec.rb[1:2:1] | passed | 0.00004 seconds |
69
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:2:2] | passed | 0.00006 seconds |
70
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:2:3] | passed | 0.00004 seconds |
71
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:1] | passed | 0.00005 seconds |
71
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:2:2] | passed | 0.00017 seconds |
72
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:2:3] | passed | 0.00011 seconds |
73
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:1] | passed | 0.00004 seconds |
72
74
  ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:2] | passed | 0.00004 seconds |
73
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:3] | passed | 0.00012 seconds |
75
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:3] | passed | 0.00013 seconds |
74
76
  ./spec/castkit/attribute_extensions/serialization_spec.rb[1:3:4] | passed | 0.00004 seconds |
75
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:4:1] | passed | 0.00047 seconds |
76
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:4:2] | passed | 0.00004 seconds |
77
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:4:1] | passed | 0.00061 seconds |
78
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:4:2] | passed | 0.00005 seconds |
77
79
  ./spec/castkit/attribute_extensions/serialization_spec.rb[1:5:1] | passed | 0.00005 seconds |
78
- ./spec/castkit/attribute_extensions/serialization_spec.rb[1:5:2] | passed | 0.00005 seconds |
80
+ ./spec/castkit/attribute_extensions/serialization_spec.rb[1:5:2] | passed | 0.00004 seconds |
79
81
  ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:1:1] | passed | 0.00014 seconds |
80
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:2:1:1] | passed | 0.00011 seconds |
81
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:2:2:1] | passed | 0.00018 seconds |
82
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:3:1] | passed | 0.00009 seconds |
83
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:4:1:1] | passed | 0.00026 seconds |
84
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:4:2:1] | passed | 0.00023 seconds |
85
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:5:1:1] | passed | 0.00011 seconds |
86
- ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:5:2:1] | passed | 0.00013 seconds |
87
- ./spec/castkit/attribute_spec.rb[1:1:1] | passed | 0.00006 seconds |
82
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:2:1:1] | passed | 0.0001 seconds |
83
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:2:2:1] | passed | 0.00016 seconds |
84
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:3:1] | passed | 0.00008 seconds |
85
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:4:1:1] | passed | 0.00009 seconds |
86
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:4:2:1] | passed | 0.00012 seconds |
87
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:5:1:1] | passed | 0.00008 seconds |
88
+ ./spec/castkit/attribute_extensions/validation_spec.rb[1:1:5:2:1] | passed | 0.00011 seconds |
89
+ ./spec/castkit/attribute_spec.rb[1:1:1] | passed | 0.00005 seconds |
88
90
  ./spec/castkit/attribute_spec.rb[1:1:2] | passed | 0.00003 seconds |
89
91
  ./spec/castkit/attribute_spec.rb[1:1:3] | passed | 0.00003 seconds |
90
92
  ./spec/castkit/attribute_spec.rb[1:1:4] | passed | 0.00003 seconds |
91
- ./spec/castkit/attribute_spec.rb[1:2:1] | passed | 0.00128 seconds |
92
- ./spec/castkit/attribute_spec.rb[1:3:1:1] | passed | 0.00007 seconds |
93
- ./spec/castkit/attribute_spec.rb[1:3:2:1] | passed | 0.00004 seconds |
94
- ./spec/castkit/attribute_spec.rb[1:3:3:1] | passed | 0.00006 seconds |
95
- ./spec/castkit/attribute_spec.rb[1:4:1] | passed | 0.00004 seconds |
96
- ./spec/castkit/attribute_spec.rb[1:4:2] | passed | 0.00004 seconds |
93
+ ./spec/castkit/attribute_spec.rb[1:2:1] | passed | 0.00127 seconds |
94
+ ./spec/castkit/attribute_spec.rb[1:3:1:1] | passed | 0.00008 seconds |
95
+ ./spec/castkit/attribute_spec.rb[1:3:2:1] | passed | 0.00005 seconds |
96
+ ./spec/castkit/attribute_spec.rb[1:3:3:1] | passed | 0.00007 seconds |
97
+ ./spec/castkit/attribute_spec.rb[1:4:1] | passed | 0.00008 seconds |
98
+ ./spec/castkit/attribute_spec.rb[1:4:2] | passed | 0.00006 seconds |
97
99
  ./spec/castkit/attribute_spec.rb[1:4:3] | passed | 0.00003 seconds |
98
- ./spec/castkit/attribute_spec.rb[1:4:4] | passed | 0.00004 seconds |
99
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:1] | passed | 0.00004 seconds |
100
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:2] | passed | 0.00003 seconds |
101
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:3] | passed | 0.00004 seconds |
100
+ ./spec/castkit/attribute_spec.rb[1:4:4] | passed | 0.00006 seconds |
101
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:1] | passed | 0.00006 seconds |
102
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:2] | passed | 0.00004 seconds |
103
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:3] | passed | 0.00003 seconds |
102
104
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:4] | passed | 0.00003 seconds |
103
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:5] | passed | 0.00003 seconds |
105
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:5] | passed | 0.00004 seconds |
104
106
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:6] | passed | 0.00003 seconds |
105
107
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:7] | passed | 0.00003 seconds |
106
108
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:8] | passed | 0.00003 seconds |
107
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:9] | passed | 0.00004 seconds |
108
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:10] | passed | 0.00004 seconds |
109
- ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:11] | passed | 0.00003 seconds |
109
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:9] | passed | 0.00003 seconds |
110
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:10] | passed | 0.00005 seconds |
111
+ ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:11] | passed | 0.00004 seconds |
110
112
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:12] | passed | 0.00003 seconds |
111
113
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:13] | passed | 0.00003 seconds |
112
114
  ./spec/castkit/data_object_extensions/attribute_types_spec.rb[1:1:14] | passed | 0.00003 seconds |
113
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:1:1] | passed | 0.00005 seconds |
114
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:1:2] | passed | 0.00005 seconds |
115
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:1:1] | passed | 0.00008 seconds |
116
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:1:2] | passed | 0.00006 seconds |
115
117
  ./spec/castkit/data_object_extensions/attributes_spec.rb[1:1:3] | passed | 0.00006 seconds |
116
118
  ./spec/castkit/data_object_extensions/attributes_spec.rb[1:2:1] | passed | 0.00004 seconds |
117
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:3:1] | passed | 0.00004 seconds |
118
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:4:1] | passed | 0.00052 seconds |
119
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:5:1] | passed | 0.00006 seconds |
120
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:6:1] | passed | 0.00006 seconds |
121
- ./spec/castkit/data_object_extensions/attributes_spec.rb[1:7:1] | passed | 0.00004 seconds |
122
- ./spec/castkit/data_object_extensions/config_spec.rb[1:1:1] | passed | 0.00004 seconds |
119
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:3:1] | passed | 0.00006 seconds |
120
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:4:1] | passed | 0.00102 seconds |
121
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:5:1] | passed | 0.0001 seconds |
122
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:6:1] | passed | 0.00007 seconds |
123
+ ./spec/castkit/data_object_extensions/attributes_spec.rb[1:7:1] | passed | 0.00005 seconds |
124
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:1:1] | passed | 0.00006 seconds |
123
125
  ./spec/castkit/data_object_extensions/config_spec.rb[1:1:2] | passed | 0.00004 seconds |
124
- ./spec/castkit/data_object_extensions/config_spec.rb[1:2:1] | passed | 0.00003 seconds |
125
- ./spec/castkit/data_object_extensions/config_spec.rb[1:2:2] | passed | 0.00003 seconds |
126
- ./spec/castkit/data_object_extensions/config_spec.rb[1:3:1] | passed | 0.00004 seconds |
127
- ./spec/castkit/data_object_extensions/config_spec.rb[1:3:2] | passed | 0.00003 seconds |
126
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:2:1] | passed | 0.00004 seconds |
127
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:2:2] | passed | 0.00004 seconds |
128
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:3:1] | passed | 0.00003 seconds |
129
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:3:2] | passed | 0.00004 seconds |
128
130
  ./spec/castkit/data_object_extensions/config_spec.rb[1:4:1] | passed | 0.00004 seconds |
129
131
  ./spec/castkit/data_object_extensions/config_spec.rb[1:5:1] | passed | 0.00003 seconds |
130
132
  ./spec/castkit/data_object_extensions/config_spec.rb[1:5:2] | passed | 0.00003 seconds |
131
133
  ./spec/castkit/data_object_extensions/config_spec.rb[1:6:1] | passed | 0.00004 seconds |
132
- ./spec/castkit/data_object_extensions/config_spec.rb[1:6:2] | passed | 0.00003 seconds |
134
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:6:2] | passed | 0.00004 seconds |
133
135
  ./spec/castkit/data_object_extensions/config_spec.rb[1:7:1] | passed | 0.00004 seconds |
136
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:7:2] | passed | 0.00004 seconds |
134
137
  ./spec/castkit/data_object_extensions/config_spec.rb[1:8:1] | passed | 0.00004 seconds |
135
- ./spec/castkit/data_object_extensions/config_spec.rb[1:8:2] | passed | 0.00003 seconds |
136
- ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:1:1] | passed | 0.0001 seconds |
137
- ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:2:1] | passed | 0.00005 seconds |
138
- ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:2:2] | passed | 0.00005 seconds |
139
- ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:3:1] | passed | 0.00017 seconds |
140
- ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:4:1] | passed | 0.00119 seconds |
141
- ./spec/castkit/data_object_spec.rb[1:1:1] | passed | 0.00012 seconds |
142
- ./spec/castkit/data_object_spec.rb[1:1:2] | passed | 0.00008 seconds |
143
- ./spec/castkit/data_object_spec.rb[1:1:3] | passed | 0.00006 seconds |
144
- ./spec/castkit/data_object_spec.rb[1:2:1] | passed | 0.00005 seconds |
145
- ./spec/castkit/data_object_spec.rb[1:2:2] | passed | 0.00005 seconds |
146
- ./spec/castkit/data_object_spec.rb[1:3:1] | passed | 0.00011 seconds |
147
- ./spec/castkit/data_object_spec.rb[1:4:1] | passed | 0.00006 seconds |
148
- ./spec/castkit/data_object_spec.rb[1:4:2] | passed | 0.00006 seconds |
149
- ./spec/castkit/data_object_spec.rb[1:4:3] | passed | 0.00006 seconds |
150
- ./spec/castkit/data_object_spec.rb[1:4:4] | passed | 0.00343 seconds |
151
- ./spec/castkit/data_object_spec.rb[1:5:1] | passed | 0.00013 seconds |
152
- ./spec/castkit/data_object_spec.rb[1:6:1] | passed | 0.00008 seconds |
138
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:9:1] | passed | 0.00004 seconds |
139
+ ./spec/castkit/data_object_extensions/config_spec.rb[1:9:2] | passed | 0.00004 seconds |
140
+ ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:1:1] | passed | 0.00013 seconds |
141
+ ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:2:1] | passed | 0.00006 seconds |
142
+ ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:2:2] | passed | 0.00006 seconds |
143
+ ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:3:1] | passed | 0.00026 seconds |
144
+ ./spec/castkit/data_object_extensions/deserialization_spec.rb[1:4:1] | passed | 0.00097 seconds |
145
+ ./spec/castkit/data_object_spec.rb[1:1:1] | passed | 0.00014 seconds |
146
+ ./spec/castkit/data_object_spec.rb[1:1:2] | passed | 0.00009 seconds |
147
+ ./spec/castkit/data_object_spec.rb[1:1:3] | passed | 0.00008 seconds |
148
+ ./spec/castkit/data_object_spec.rb[1:2:1] | passed | 0.0001 seconds |
149
+ ./spec/castkit/data_object_spec.rb[1:2:2] | passed | 0.0001 seconds |
150
+ ./spec/castkit/data_object_spec.rb[1:3:1] | passed | 0.00012 seconds |
151
+ ./spec/castkit/data_object_spec.rb[1:4:1] | passed | 0.00008 seconds |
152
+ ./spec/castkit/data_object_spec.rb[1:4:2] | passed | 0.00008 seconds |
153
+ ./spec/castkit/data_object_spec.rb[1:4:3] | passed | 0.00016 seconds |
154
+ ./spec/castkit/data_object_spec.rb[1:4:4] | passed | 0.00008 seconds |
155
+ ./spec/castkit/data_object_spec.rb[1:4:5] | passed | 0.00077 seconds |
156
+ ./spec/castkit/data_object_spec.rb[1:4:6] | passed | 0.00025 seconds |
157
+ ./spec/castkit/data_object_spec.rb[1:4:7] | passed | 0.00012 seconds |
158
+ ./spec/castkit/data_object_spec.rb[1:5:1] | passed | 0.00008 seconds |
159
+ ./spec/castkit/data_object_spec.rb[1:6:1] | passed | 0.0001 seconds |
160
+ ./spec/castkit/data_object_spec.rb[1:7:1] | passed | 0.00011 seconds |
161
+ ./spec/castkit/data_object_spec.rb[1:7:2] | passed | 0.00016 seconds |
162
+ ./spec/castkit/data_object_spec.rb[1:8:1] | passed | 0.00011 seconds |
153
163
  ./spec/castkit/default_serializer_spec.rb[1:1:1] | passed | 0.0001 seconds |
154
- ./spec/castkit/default_serializer_spec.rb[1:2:1] | passed | 0.00024 seconds |
155
- ./spec/castkit/default_serializer_spec.rb[1:2:2] | passed | 0.00007 seconds |
156
- ./spec/castkit/default_serializer_spec.rb[1:3:1] | passed | 0.00009 seconds |
164
+ ./spec/castkit/default_serializer_spec.rb[1:2:1] | passed | 0.00013 seconds |
165
+ ./spec/castkit/default_serializer_spec.rb[1:2:2] | passed | 0.00014 seconds |
166
+ ./spec/castkit/default_serializer_spec.rb[1:2:3] | passed | 0.00015 seconds |
167
+ ./spec/castkit/default_serializer_spec.rb[1:3:1] | passed | 0.00008 seconds |
157
168
  ./spec/castkit/default_serializer_spec.rb[1:3:2] | passed | 0.00014 seconds |
158
- ./spec/castkit/default_serializer_spec.rb[1:3:3] | passed | 0.00024 seconds |
159
- ./spec/castkit/default_serializer_spec.rb[1:3:4] | passed | 0.00011 seconds |
160
- ./spec/castkit/default_serializer_spec.rb[1:4:1] | passed | 0.00007 seconds |
169
+ ./spec/castkit/default_serializer_spec.rb[1:3:3] | passed | 0.00015 seconds |
170
+ ./spec/castkit/default_serializer_spec.rb[1:3:4] | passed | 0.00018 seconds |
171
+ ./spec/castkit/default_serializer_spec.rb[1:4:1] | passed | 0.00008 seconds |
161
172
  ./spec/castkit/default_serializer_spec.rb[1:5:1] | passed | 0.00007 seconds |
162
- ./spec/castkit/default_serializer_spec.rb[1:5:2] | passed | 0.00006 seconds |
163
- ./spec/castkit/default_serializer_spec.rb[1:5:3] | passed | 0.00013 seconds |
173
+ ./spec/castkit/default_serializer_spec.rb[1:5:2] | passed | 0.00007 seconds |
174
+ ./spec/castkit/default_serializer_spec.rb[1:5:3] | passed | 0.00006 seconds |
164
175
  ./spec/castkit/serializer_spec.rb[1:1:1] | passed | 0.00004 seconds |
165
- ./spec/castkit/serializer_spec.rb[1:2:1] | passed | 0.00012 seconds |
166
- ./spec/castkit/serializer_spec.rb[1:3:1] | passed | 0.00006 seconds |
167
- ./spec/castkit/serializer_spec.rb[1:3:2] | passed | 0.00005 seconds |
176
+ ./spec/castkit/serializer_spec.rb[1:2:1] | passed | 0.00014 seconds |
177
+ ./spec/castkit/serializer_spec.rb[1:3:1] | passed | 0.00007 seconds |
178
+ ./spec/castkit/serializer_spec.rb[1:3:2] | passed | 0.00011 seconds |
168
179
  ./spec/castkit/serializer_spec.rb[1:4:1] | passed | 0.00004 seconds |
169
- ./spec/castkit/validator_spec.rb[1:1:1] | passed | 0.00004 seconds |
170
- ./spec/castkit/validator_spec.rb[1:2:1] | passed | 0.00003 seconds |
171
- ./spec/castkit/validators/numeric_validator_spec.rb[1:1:1:1] | passed | 0.00004 seconds |
180
+ ./spec/castkit/validator_spec.rb[1:1:1] | passed | 0.00003 seconds |
181
+ ./spec/castkit/validator_spec.rb[1:2:1] | passed | 0.00004 seconds |
182
+ ./spec/castkit/validators/numeric_validator_spec.rb[1:1:1:1] | passed | 0.00005 seconds |
172
183
  ./spec/castkit/validators/numeric_validator_spec.rb[1:1:2:1] | passed | 0.00004 seconds |
173
- ./spec/castkit/validators/numeric_validator_spec.rb[1:1:3:1] | passed | 0.00003 seconds |
184
+ ./spec/castkit/validators/numeric_validator_spec.rb[1:1:3:1] | passed | 0.00004 seconds |
174
185
  ./spec/castkit/validators/numeric_validator_spec.rb[1:1:4:1] | passed | 0.00003 seconds |
175
186
  ./spec/castkit/validators/string_validator_spec.rb[1:1:1:1:1] | passed | 0.00004 seconds |
176
187
  ./spec/castkit/validators/string_validator_spec.rb[1:1:1:1:2] | passed | 0.00004 seconds |
177
188
  ./spec/castkit/validators/string_validator_spec.rb[1:1:2:1] | passed | 0.00004 seconds |
178
189
  ./spec/castkit/validators/string_validator_spec.rb[1:1:2:2] | passed | 0.00003 seconds |
179
- ./spec/castkit/validators/string_validator_spec.rb[1:1:3:1] | passed | 0.00004 seconds |
180
- ./spec/castkit/validators/string_validator_spec.rb[1:1:3:2] | passed | 0.00003 seconds |
181
- ./spec/castkit/validators/string_validator_spec.rb[1:1:4:1] | passed | 0.00004 seconds |
182
- ./spec/castkit_spec.rb[1:1] | passed | 0.00003 seconds |
183
- ./spec/castkit_spec.rb[1:2:1:1] | passed | 0.00009 seconds |
184
- ./spec/castkit_spec.rb[1:2:1:2] | passed | 0.00006 seconds |
185
- ./spec/castkit_spec.rb[1:2:1:3] | passed | 0.00008 seconds |
186
- ./spec/castkit_spec.rb[1:2:1:4] | passed | 0.00007 seconds |
187
- ./spec/castkit_spec.rb[1:2:2:1] | passed | 0.00006 seconds |
188
- ./spec/castkit_spec.rb[1:2:2:2] | passed | 0.00009 seconds |
189
- ./spec/castkit_spec.rb[1:2:2:3] | passed | 0.00005 seconds |
190
+ ./spec/castkit/validators/string_validator_spec.rb[1:1:3:1] | passed | 0.00005 seconds |
191
+ ./spec/castkit/validators/string_validator_spec.rb[1:1:3:2] | passed | 0.00011 seconds |
192
+ ./spec/castkit/validators/string_validator_spec.rb[1:1:4:1] | passed | 0.00008 seconds |
193
+ ./spec/castkit_spec.rb[1:1] | passed | 0.00004 seconds |
194
+ ./spec/castkit_spec.rb[1:2:1:1] | passed | 0.00012 seconds |
195
+ ./spec/castkit_spec.rb[1:2:1:2] | passed | 0.00007 seconds |
196
+ ./spec/castkit_spec.rb[1:2:1:3] | passed | 0.00009 seconds |
197
+ ./spec/castkit_spec.rb[1:2:1:4] | passed | 0.00008 seconds |
198
+ ./spec/castkit_spec.rb[1:2:2:1] | passed | 0.00008 seconds |
199
+ ./spec/castkit_spec.rb[1:2:2:2] | passed | 0.00005 seconds |
200
+ ./spec/castkit_spec.rb[1:2:2:3] | passed | 0.00012 seconds |
190
201
  ./spec/castkit_spec.rb[1:2:3:1] | passed | 0.00005 seconds |
191
- ./spec/castkit_spec.rb[1:2:3:2] | passed | 0.00005 seconds |
192
- ./spec/castkit_spec.rb[1:2:3:3] | passed | 0.00004 seconds |
202
+ ./spec/castkit_spec.rb[1:2:3:2] | passed | 0.00006 seconds |
203
+ ./spec/castkit_spec.rb[1:2:3:3] | passed | 0.00005 seconds |
193
204
  ./spec/castkit_spec.rb[1:2:4:1] | passed | 0.00006 seconds |
194
- ./spec/castkit_spec.rb[1:3:1] | passed | 0.00014 seconds |
195
- ./spec/castkit_spec.rb[1:3:2] | passed | 0.00029 seconds |
196
- ./spec/castkit_spec.rb[1:3:3] | passed | 0.00016 seconds |
197
- ./spec/castkit_spec.rb[1:3:4] | passed | 0.00012 seconds |
198
- ./spec/castkit_spec.rb[1:3:5] | passed | 0.00016 seconds |
205
+ ./spec/castkit_spec.rb[1:3:1] | passed | 0.00015 seconds |
206
+ ./spec/castkit_spec.rb[1:3:2] | passed | 0.00018 seconds |
207
+ ./spec/castkit_spec.rb[1:3:3] | passed | 0.00015 seconds |
208
+ ./spec/castkit_spec.rb[1:3:4] | passed | 0.00017 seconds |
209
+ ./spec/castkit_spec.rb[1:3:5] | passed | 0.00009 seconds |
199
210
  ./spec/castkit_spec.rb[1:3:6] | passed | 0.0001 seconds |
200
- ./spec/castkit_spec.rb[1:3:7] | passed | 0.0001 seconds |
201
- ./spec/castkit_spec.rb[1:3:8] | passed | 0.00017 seconds |
202
- ./spec/configuration_spec.rb[1:1:1] | passed | 0.00005 seconds |
211
+ ./spec/castkit_spec.rb[1:3:7] | passed | 0.00017 seconds |
212
+ ./spec/castkit_spec.rb[1:3:8] | passed | 0.00018 seconds |
213
+ ./spec/configuration_spec.rb[1:1:1] | passed | 0.00006 seconds |
203
214
  ./spec/configuration_spec.rb[1:2:1] | passed | 0.00004 seconds |
204
215
  ./spec/configuration_spec.rb[1:3:1] | passed | 0.00004 seconds |
205
216
  ./spec/configuration_spec.rb[1:3:2] | passed | 0.00003 seconds |
data/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2025-04-10
3
+ ## [0.1.2] - 2025-04-14
4
+
5
+ ### Added
6
+
7
+ - **`allow_unknown` Configuration in `Castkit::DataObject`**:
8
+ - Introduced a new configuration option, `allow_unknown`, which controls whether unknown attributes during deserialization are allowed.
9
+ - If `allow_unknown` is set to `true`, unknown attributes will be captured and included in the object's `unknown_attributes` hash.
10
+ - If `allow_unknown` is set to `false`, unknown attributes will either raise an error or log a warning based on the `strict` configuration.
11
+ - If `allow_unknown` is enabled, it overrides the `strict` setting, disabling strict validation for unknown keys.
12
+
13
+ ```ruby
14
+ class UserDto < Castkit::DataObject
15
+ allow_unknown true
16
+ string :id
17
+ end
18
+
19
+ user = UserDto.new(id: 123, name: 'Castkit')
20
+ user.to_h # { id: 123, name: 'Castkit' }
21
+ ```
22
+ - **`enable_warnings` Configuration flag in `Castkit.configure`**:
23
+ - Added a new flag `enable_warnings` to the `Castkit.configure` block, which controls whether warnings (such as those for unknown attributes) are emitted.
24
+ - Defaults to `true`, enabling warnings by default. Set to `false` to suppress warnings globally.
25
+
26
+ ```ruby
27
+ Castkit.configure do |config|
28
+ config.enable_warnings = false
29
+ end
30
+ ```
31
+
32
+ ## [0.1.1] - 2025-04-13
33
+
34
+ ### Added
35
+
36
+ - `Castkit::Attribute#dataobject_collection?`
37
+
38
+ A new helper method that returns `true` if the attribute is an array of `Castkit::DataObject` instances.
39
+ This is determined by checking if the attribute's type is `:array` and the `:of` option is a Castkit::DataObject class.
40
+
41
+ ```ruby
42
+ attribute = Castkit::Attribute.new(:comments, :array, of: CommentDto)
43
+ attribute.dataobject_collection? # => true
44
+ ```
45
+
46
+ Useful when working with nested DataObject collections (e.g., for integration with ActiveRecord or serialization logic).
47
+
48
+ ## [0.1.0] - 2025-04-12
4
49
 
5
50
  - Initial release
data/README.md CHANGED
@@ -191,5 +191,5 @@ MIT. See [LICENSE](LICENSE).
191
191
 
192
192
  ## 🙏 Credits
193
193
 
194
- Created with ❤️ by [Nathan Lucas](https://github.com/you)
194
+ Created with ❤️ by [Nathan Lucas](https://github.com/bnlucas)
195
195
  Inspired by Java DTOs, dry-rb, and the need for clean, reliable data structures in APIs.
@@ -75,7 +75,7 @@ module Castkit
75
75
  message = message_fn.call(self, **kwargs)
76
76
  raise error_class.new(message, context: context) if Castkit.configuration.public_send(config_key)
77
77
 
78
- warn "[Castkit] #{message}"
78
+ Castkit.warning "[Castkit] #{message}"
79
79
  nil
80
80
  end
81
81
  end
@@ -97,6 +97,13 @@ module Castkit
97
97
  Castkit.dataobject?(type)
98
98
  end
99
99
 
100
+ # Whether the attribute is a collection of Castkit::DataObjects.
101
+ #
102
+ # @return [Boolean]
103
+ def dataobject_collection?
104
+ type == :array && Castkit.dataobject?(options[:of])
105
+ end
106
+
100
107
  # Whether the attribute is considered composite (not exposed in serialized output).
101
108
  #
102
109
  # @return [Boolean]
@@ -10,9 +10,9 @@ module Castkit
10
10
  #
11
11
  # If the value is a Castkit::DataObject, a custom serializer is used if configured.
12
12
  #
13
- # @param value [Object] the value to serialize
13
+ # @param value [Object, nil] the value to serialize
14
14
  # @param visited [Set, nil] used for circular reference detection
15
- # @return [Object] the serialized value
15
+ # @return [Object, nil] the serialized value
16
16
  def dump(value, visited: nil)
17
17
  return value if value.nil?
18
18
 
@@ -48,9 +48,9 @@ module Castkit
48
48
  # - Uses a serializer if the value is a Castkit::DataObject.
49
49
  # - Converts `to_h` if the value is hash-like.
50
50
  #
51
- # @param value [Object] the element to dump
51
+ # @param value [Object, nil] the element to dump
52
52
  # @param visited [Set, nil]
53
- # @return [Object]
53
+ # @return [Object, nil]
54
54
  def dump_element(value, visited: nil)
55
55
  return value if value.nil? || primitive?(value)
56
56
 
@@ -66,7 +66,7 @@ module Castkit
66
66
 
67
67
  # Checks whether a value is a hashable object suitable for `to_h` dumping.
68
68
  #
69
- # @param value [Object]
69
+ # @param value [Object, nil]
70
70
  # @return [Boolean]
71
71
  def hashable?(value)
72
72
  value.respond_to?(:to_h) && !primitive?(value) && !value.is_a?(Castkit::Attribute)
@@ -74,7 +74,7 @@ module Castkit
74
74
 
75
75
  # Determines if a value is a primitive type.
76
76
  #
77
- # @param value [Object]
77
+ # @param value [Object, nil]
78
78
  # @return [Boolean]
79
79
  def primitive?(value)
80
80
  case value
@@ -37,6 +37,18 @@ module Castkit
37
37
  @configuration ||= Configuration.new
38
38
  end
39
39
 
40
+ # Generates a warning message if configuration.enable_warnings == true.
41
+ #
42
+ # @param message [String] The warning message
43
+ # @return [void]
44
+ def warning(message)
45
+ warn message if configuration.enable_warnings
46
+ end
47
+
48
+ # Determine if an object is a subclass of Castkit::DataObject.
49
+ #
50
+ # @param obj [Object] The object to check
51
+ # @return [Boolean]
40
52
  def dataobject?(obj)
41
53
  obj.is_a?(Class) && obj.ancestors.include?(Castkit::DataObject)
42
54
  end
@@ -47,6 +47,10 @@ module Castkit
47
47
  # @return [Boolean]
48
48
  attr_accessor :enforce_array_options
49
49
 
50
+ # Whether to generating warnings or not, defaults to `true`.
51
+ # @return [Boolean]
52
+ attr_accessor :enable_warnings
53
+
50
54
  # Initializes the configuration with default validators and enforcement settings.
51
55
  #
52
56
  # @return [void]
@@ -59,6 +63,7 @@ module Castkit
59
63
  @enforce_attribute_access = true
60
64
  @enforce_unwrapped_prefix = true
61
65
  @enforce_array_options = true
66
+ @enable_warnings = true
62
67
  end
63
68
 
64
69
  # Registers a custom validator for a given type.
@@ -72,15 +72,26 @@ module Castkit
72
72
  end
73
73
  end
74
74
 
75
+ # @return [Hash{Symbol => Object}] The raw data provided during instantiation.
76
+ attr_reader :__raw
77
+
78
+ # @return [Hash{Symbol => Object}] Undefined attributes provided during instantiation.
79
+ attr_reader :unknown_attributes
80
+
75
81
  # Initializes the DTO from a hash of attributes.
76
82
  #
77
83
  # @param fields [Hash] raw input hash
78
84
  # @raise [Castkit::DataObjectError] if strict mode is enabled and unknown keys are present
79
85
  def initialize(fields = {})
86
+ @__raw = fields
87
+
80
88
  root = self.class.root
81
89
  fields = fields[root] if root && fields.key?(root)
82
90
  fields = unwrap_prefixed_fields!(fields)
83
91
 
92
+ @unknown_attributes = fields.reject { |key, _| self.class.attributes.key?(key.to_sym) }
93
+
94
+ validate_access_config!
84
95
  validate_keys!(fields)
85
96
  deserialize_attributes!(fields)
86
97
  end
@@ -128,19 +139,32 @@ module Castkit
128
139
  handle_unknown_keys!(unknown_keys)
129
140
  end
130
141
 
142
+ # Validates the `strict` and `allow_unknown` config flags and generates a warning if they are conflicting.
143
+ # - If strict == true, allow_unknown cannot be true.
144
+ # - If strict == false, allow_unknown can be true | false.
145
+ #
146
+ # @return [void]
147
+ def validate_access_config!
148
+ return unless self.class.strict && self.class.allow_unknown
149
+
150
+ Castkit.warning "⚠️ [Castkit] Both `strict` and `allow_unknown` are enabled, which can lead to " \
151
+ "conflicting behavior. `strict` is being disabled to respect `allow_unknown`."
152
+ end
153
+
131
154
  # Handles unknown keys found during initialization.
132
155
  #
133
156
  # Behavior depends on the class-level configuration:
134
157
  # - Raises a `Castkit::DataObjectError` if strict mode is enabled.
135
- # - Logs a warning if `warn_on_unknown` is enabled.
158
+ # - Logs a warning if `warn_on_unknown` is enabled and `allow_unknown` is false.
136
159
  #
137
- # @param unknown_keys [Array<Symbol>] list of unknown keys not declared as attributes or aliases
138
- # @raise [Castkit::DataObjectError] if strict mode is active
160
+ # @param unknown_keys [Array<Symbol>] List of unknown keys not declared as attributes or aliases.
161
+ # @raise [Castkit::DataObjectError] If `strict` mode is enabled and unknown keys are found.
139
162
  # @return [void]
140
163
  def handle_unknown_keys!(unknown_keys)
141
- raise Castkit::DataObjectError, "Unknown attribute(s): #{unknown_keys.join(", ")}" if self.class.strict
164
+ raise Castkit::DataObjectError, "Unknown attribute(s): #{unknown_keys.join(", ")}" if strict?
165
+ return unless self.class.warn_on_unknown
142
166
 
143
- warn "⚠️ [Castkit] Unknown attribute(s) ignored: #{unknown_keys.join(", ")}" if self.class.warn_on_unknown
167
+ Castkit.warning "⚠️ [Castkit] Unknown attribute(s) ignored: #{unknown_keys.join(", ")}"
144
168
  end
145
169
 
146
170
  # Returns the serializer instance or default for this object.
@@ -149,5 +173,12 @@ module Castkit
149
173
  def serializer
150
174
  @serializer ||= self.class.serializer || Castkit::DefaultSerializer
151
175
  end
176
+
177
+ # Returns false if self.class.allow_unknown == true, otherwise the value of self.class.strict.
178
+ #
179
+ # @return [Boolean]
180
+ def strict?
181
+ self.class.allow_unknown ? false : !!self.class.strict
182
+ end
152
183
  end
153
184
  end
@@ -70,7 +70,15 @@ module Castkit
70
70
  # @param value [Boolean, nil]
71
71
  # @return [Boolean, nil]
72
72
  def warn_on_unknown(value = nil)
73
- value.nil? ? @warn_unknown_keys : (@warn_unknown_keys = value)
73
+ value.nil? ? @warn_on_unknown : (@warn_on_unknown = value)
74
+ end
75
+
76
+ # Sets or retrieves whether to allow unknown keys when they are encountered.
77
+ #
78
+ # @param value [Boolean, nil]
79
+ # @return [Boolean, nil]
80
+ def allow_unknown(value = nil)
81
+ value.nil? ? @allow_unknown : (@allow_unknown = value)
74
82
  end
75
83
 
76
84
  # Returns a relaxed version of the current class with strict mode off.
@@ -12,16 +12,22 @@ module Castkit
12
12
  # @return [Hash{Symbol => Castkit::Attribute}] attributes to serialize
13
13
  attr_reader :attributes
14
14
 
15
- # @return [Hash] serialization options (root key, ignore_nil, etc.)
15
+ # @return [Hash{Symbol => Object}] attributes that are not predefined or known to the object
16
+ attr_reader :unknown_attributes
17
+
18
+ # @return [Hash] serialization options (root key, ignore_nil, allow_unknown, etc.)
16
19
  attr_reader :options
17
20
 
18
21
  # Returns the serialized object as a Hash.
19
22
  #
20
- # Includes root wrapping if configured.
23
+ # Includes root wrapping if configured. If `allow_unknown` is set to true, unknown attributes
24
+ # are merged into the final result.
21
25
  #
22
- # @return [Hash]
26
+ # @return [Hash] The serialized object, potentially wrapped with a root key
23
27
  def call
24
28
  result = serialize_attributes
29
+ result.merge!(unknown_attributes) if options[:allow_unknown]
30
+
25
31
  options[:root] ? { options[:root].to_sym => result } : result
26
32
  end
27
33
 
@@ -30,40 +36,54 @@ module Castkit
30
36
  # Initializes the serializer with the target object and context.
31
37
  #
32
38
  # @param raw [Castkit::DataObject] the object to serialize
33
- # @param visited [Set, nil] used to detect circular references
39
+ # @param visited [Set, nil] used to detect circular references (default is nil)
34
40
  def initialize(raw, visited: nil)
35
41
  super
36
42
 
43
+ # Setting up attributes, unknown attributes, and options based on the class-level configuration
37
44
  @attributes = raw.class.attributes
45
+ @unknown_attributes = raw.unknown_attributes
38
46
  @options = {
39
47
  root: raw.class.root,
40
- ignore_nil: raw.class.ignore_nil
48
+ ignore_nil: raw.class.ignore_nil || false,
49
+ allow_unknown: raw.class.allow_unknown || false
41
50
  }
42
51
  end
43
52
 
44
53
  # Iterates over attributes and serializes each into a result hash.
45
54
  #
46
- # @return [Hash]
55
+ # @return [Hash] The serialized attributes as a hash
47
56
  def serialize_attributes
48
57
  attributes.each_with_object({}) do |(_, attribute), hash|
49
58
  next if attribute.skip_serialization?
50
59
 
60
+ # Serializing each attribute
51
61
  serialized_value = serialize_attribute(attribute)
52
62
  next if serialized_value == SKIP_ATTRIBUTE
53
63
 
64
+ # Assign the serialized value to the correct key in the hash
54
65
  assign_attribute_key!(hash, attribute, serialized_value)
55
66
  end
56
67
  end
57
68
 
58
69
  # Process and serialize a given attribute.
59
70
  #
60
- # @param attribute [Castkit::Attribute] The attribute instance.
61
- # @param [Object]
71
+ # This handles value extraction, skipping when nil values are encountered, and ensuring
72
+ # attributes are serialized according to their rules.
73
+ #
74
+ # @param attribute [Castkit::Attribute] The attribute instance to serialize
75
+ # @return [Object, nil] The serialized value or SKIP_ATTRIBUTE if the value should be skipped
62
76
  def serialize_attribute(attribute)
77
+ # Fetch the value of the attribute from the object
63
78
  value = obj.public_send(attribute.field)
79
+
80
+ # Skip serialization if value is nil and ignore_nil is set to true
64
81
  return SKIP_ATTRIBUTE if value.nil? && (attribute.ignore_nil? || options[:ignore_nil])
65
82
 
83
+ # Serialize the value using the attribute's dump method
66
84
  serialized_value = attribute.dump(value, visited: visited)
85
+
86
+ # Skip if value is blank and ignore_blank is set to true
67
87
  return SKIP_ATTRIBUTE if blank?(serialized_value) && (attribute.ignore_blank? || options[:ignore_blank])
68
88
 
69
89
  serialized_value
@@ -71,29 +91,33 @@ module Castkit
71
91
 
72
92
  # Assigns a serialized value into the hash using nested key paths.
73
93
  #
74
- # @param hash [Hash]
75
- # @param attribute [Castkit::Attribute]
76
- # @param value [Object]
77
- # @return [void]
94
+ # This ensures attributes with nested key paths (like `address.city`) are placed into nested hashes.
95
+ #
96
+ # @param hash [Hash] The resulting hash to populate with the serialized values
97
+ # @param attribute [Castkit::Attribute] The attribute being serialized
98
+ # @param value [Object] The serialized value
99
+ # @return [void] Updates the hash in-place
78
100
  def assign_attribute_key!(hash, attribute, value)
79
101
  key_path = attribute.key_path
80
102
  last = key_path.pop
81
103
  current = hash
82
104
 
105
+ # Traverse the key path and create nested hashes as needed
83
106
  key_path.each do |key|
84
107
  current[key] ||= {}
85
108
  current = current[key]
86
109
  end
87
110
 
111
+ # Assign the final value to the last key in the path
88
112
  current[last] = value
89
113
  end
90
114
 
91
- # Determines if a value is blank (nil or empty).
115
+ # Determines if a value is blank (nil, empty array, empty hash, empty string, etc.)
92
116
  #
93
- # @param value [Object, nil]
94
- # @return [Boolean]
117
+ # @param value [Object, nil] The value to check
118
+ # @return [Boolean] true if the value is blank, false otherwise
95
119
  def blank?(value)
96
- value.nil? || (value.respond_to?(:empty?) && value&.empty?)
120
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
97
121
  end
98
122
  end
99
123
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castkit
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lucas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-13 00:00:00.000000000 Z
11
+ date: 2025-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec