evt-schema 2.3.0.0 → 2.3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schema/controls/data_structure.rb +10 -0
- data/lib/schema/data_structure.rb +5 -2
- data/lib/schema/fixtures +1 -1
- data/lib/schema/fixtures.rb +1 -1
- data/lib/schema/scratch.rb +50 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f332c2468a6e32cfd2cfdcdea372f004c620ca7679ad146ed8c63f66d851dbc0
|
4
|
+
data.tar.gz: 3bd8893da9e6c466bba9175747402531f56df1f9cf32644297231bd1de0c502e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1a631fe2dbf4dba122f20a1fe81d8afe5b95e93297f4e0009e3e9afb907544f1f276b40e96adc5e364d387a527c1a0258251ee33abeb41c4d10463439405351
|
7
|
+
data.tar.gz: 29626ec60e70ac92def2e729a7097e2207ebdd96ca5c717129b78e64ab2db6e2c8fb64600b3a802ca46d074108d8ea30cbf818226e9972aaccf1635eae9513db
|
@@ -102,6 +102,16 @@ module Schema
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
105
|
+
|
106
|
+
module TransformReadFail
|
107
|
+
Error = Class.new(RuntimeError)
|
108
|
+
|
109
|
+
class Example < DataStructure::Example
|
110
|
+
def transform_read(data)
|
111
|
+
raise Error
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
105
115
|
end
|
106
116
|
end
|
107
117
|
end
|
@@ -24,8 +24,11 @@ module Schema
|
|
24
24
|
strict ||= false
|
25
25
|
|
26
26
|
new.tap do |instance|
|
27
|
-
|
28
|
-
|
27
|
+
if not data.empty?
|
28
|
+
instance.transform_read(data)
|
29
|
+
set_attributes(instance, data, strict)
|
30
|
+
end
|
31
|
+
|
29
32
|
instance.configure_dependencies
|
30
33
|
end
|
31
34
|
end
|
data/lib/schema/fixtures
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
/Users/sbellware/projects/eventide/schema-fixtures/lib/schema/fixtures
|
data/lib/schema/fixtures.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
/Users/sbellware/projects/eventide/schema-fixtures/lib/schema/fixtures.rb
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Foo.build
|
2
|
+
|
3
|
+
-> transform_read({})
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
class Thing
|
14
|
+
attribute :some_attribute, String
|
15
|
+
attribute :some_object, SomeClass
|
16
|
+
|
17
|
+
def self.transform_read(data)
|
18
|
+
some_object_data = data[:some_object] # => nil or some hash
|
19
|
+
|
20
|
+
if not some_object_data.nil?
|
21
|
+
foo_data = some_object_data[:foo] # => Error
|
22
|
+
end
|
23
|
+
|
24
|
+
some_object = SomeClass.build(some_object_data)
|
25
|
+
|
26
|
+
data[:some_object] = some_object
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class SomeClass
|
31
|
+
attribute :foo
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
data = {}
|
36
|
+
thing = Thing.build(data)
|
37
|
+
|
38
|
+
build(data) -> transform_read(data) # Rem: data is empty
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
thing = data[:some_atttribute]
|
47
|
+
# => nil
|
48
|
+
|
49
|
+
thing.other_thing
|
50
|
+
# => nil reference error
|
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.0.
|
4
|
+
version: 2.3.0.1
|
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:
|
11
|
+
date: 2022-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- lib/schema/schema/compare.rb
|
118
118
|
- lib/schema/schema/compare/comparison.rb
|
119
119
|
- lib/schema/schema/compare/comparison/entry.rb
|
120
|
+
- lib/schema/scratch.rb
|
120
121
|
- lib/schema/validation/error.rb
|
121
122
|
- lib/schema/validation/nil_attributes.rb
|
122
123
|
homepage: https://github.com/eventide-project/schema
|
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
139
|
- !ruby/object:Gem::Version
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
142
|
+
rubygems_version: 3.3.3
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Primitives for schema and data structure
|