evt-schema 2.3.0.2 → 2.3.1.4
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/schema/controls/data_structure.rb +15 -2
- data/lib/schema/schema.rb +23 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 971bea799a068571a832fd0d91d795d358b4bf2353815af0deeba7bd06575f2b
|
4
|
+
data.tar.gz: ce668827143bc600c0cff547599342ef8b407360532645b31fa316e6b183cb6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f574566d0440bfee26e16529dcd2d577c29d7a38ec6db7a50d8b2241f100fd3fbb31a6a8138983b8c48d006576f2d73505a90359b80d73b62b0382bd7a052107
|
7
|
+
data.tar.gz: 5a5d352f13748253fb1a0b499d21305e2a750c14ca2e4d0d6026fcb2f9e53650199e1a7280fdd20585c4a9faad55ccc15b680875b7559dfeb96daf3c48c7b031
|
@@ -27,6 +27,7 @@ module Schema
|
|
27
27
|
|
28
28
|
class Example
|
29
29
|
include ::Schema::DataStructure
|
30
|
+
|
30
31
|
attribute :some_attribute
|
31
32
|
end
|
32
33
|
|
@@ -66,7 +67,11 @@ module Schema
|
|
66
67
|
example
|
67
68
|
end
|
68
69
|
|
69
|
-
class Example
|
70
|
+
class Example
|
71
|
+
include ::Schema::DataStructure
|
72
|
+
|
73
|
+
attribute :some_attribute
|
74
|
+
|
70
75
|
def transform_read(data)
|
71
76
|
data[:some_attribute] = 'some read value'
|
72
77
|
end
|
@@ -91,7 +96,11 @@ module Schema
|
|
91
96
|
example
|
92
97
|
end
|
93
98
|
|
94
|
-
class Example
|
99
|
+
class Example
|
100
|
+
include ::Schema::DataStructure
|
101
|
+
|
102
|
+
attribute :some_attribute
|
103
|
+
|
95
104
|
def transform_in(data)
|
96
105
|
data[:some_attribute] = 'some read value'
|
97
106
|
end
|
@@ -107,6 +116,10 @@ module Schema
|
|
107
116
|
Error = Class.new(RuntimeError)
|
108
117
|
|
109
118
|
class Example < DataStructure::Example
|
119
|
+
include ::Schema::DataStructure
|
120
|
+
|
121
|
+
attribute :some_attribute
|
122
|
+
|
110
123
|
def transform_read(data)
|
111
124
|
raise Error
|
112
125
|
end
|
data/lib/schema/schema.rb
CHANGED
@@ -41,7 +41,7 @@ module Schema
|
|
41
41
|
|
42
42
|
check = proc do |val|
|
43
43
|
unless val.nil? || Boolean.(val)
|
44
|
-
raise Schema::Attribute::TypeError, "#{val.inspect}
|
44
|
+
raise Schema::Attribute::TypeError, "#{val.inspect} of type #{val.class.name} cannot be assigned to attribute #{attribute_name} of type Boolean (Strict: #{strict.inspect})"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
elsif !type.nil?
|
@@ -50,9 +50,13 @@ module Schema
|
|
50
50
|
check = proc do |val|
|
51
51
|
unless val.nil?
|
52
52
|
if strict
|
53
|
-
|
53
|
+
if not val.instance_of?(type)
|
54
|
+
raise Schema::Attribute::TypeError, "#{val.inspect} of type #{val.class.name} cannot be assigned to attribute #{attribute_name} of type #{type.name} (Strict: #{strict.inspect})"
|
55
|
+
end
|
54
56
|
else
|
55
|
-
|
57
|
+
if not val.is_a?(type)
|
58
|
+
raise Schema::Attribute::TypeError, "#{val.inspect} of type #{val.class.name} cannot be assigned to attribute #{attribute_name} of type #{type.name} (Strict: #{strict.inspect})"
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
@@ -161,14 +165,23 @@ module Schema
|
|
161
165
|
end
|
162
166
|
end
|
163
167
|
|
168
|
+
def raw_attributes
|
169
|
+
all_attribute_names = self.class.all_attribute_names
|
170
|
+
get_attributes(all_attribute_names)
|
171
|
+
end
|
172
|
+
|
173
|
+
def get_attributes(attribute_names)
|
174
|
+
attribute_names.each_with_object({}) do |attribute_name, attributes|
|
175
|
+
attributes[attribute_name] = public_send(attribute_name)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
164
179
|
def attributes(include_transient: nil)
|
165
180
|
include_transient ||= false
|
166
181
|
|
167
182
|
attribute_names = self.class.attribute_names(include_transient: include_transient)
|
168
183
|
|
169
|
-
data = attribute_names
|
170
|
-
attributes[attribute_name] = public_send(attribute_name)
|
171
|
-
end
|
184
|
+
data = get_attributes(attribute_names)
|
172
185
|
|
173
186
|
transform_write(data)
|
174
187
|
|
@@ -197,4 +210,8 @@ module Schema
|
|
197
210
|
!different
|
198
211
|
end
|
199
212
|
alias :eql? :==
|
213
|
+
|
214
|
+
def hash
|
215
|
+
[self.class, raw_attributes].hash
|
216
|
+
end
|
200
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-schema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|