evt-schema 2.2.6.1 → 2.3.0.0
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/schema.rb +32 -11
- data/lib/schema/schema/compare/comparison.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6298a47ba57d055166492488cc80134821dc6c8854623a1828ab126beeb2f05f
|
4
|
+
data.tar.gz: c8bbcbc6d8ada0ce2169b1aa35cba6f117bd03928511d320fa4040820a65cd0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c0b44340c1d7dacb2eaff58411ddbf8e0decf77fc132590c290a7aed8314b719446076eb88e25ecd7a795ae1298e90416bd58f476a8ea5bc6a1ef89648ce5d8
|
7
|
+
data.tar.gz: bd84b8ee4f51e07275fc1b21bc44edc275cc33985bc0b20148a825fcd796bdd902e9fd4f17228e18493e08248c92b1c79c3597da9e6214ddeb3807a5f0fa04d6
|
data/lib/schema/schema.rb
CHANGED
@@ -78,7 +78,9 @@ module Schema
|
|
78
78
|
@attributes ||= AttributeRegistry.new
|
79
79
|
end
|
80
80
|
|
81
|
-
def attribute_names
|
81
|
+
def attribute_names(include_transient: nil)
|
82
|
+
include_transient ||= false
|
83
|
+
|
82
84
|
transient_attributes = []
|
83
85
|
if respond_to?(:transient_attributes)
|
84
86
|
transient_attributes = self.transient_attributes
|
@@ -86,12 +88,20 @@ module Schema
|
|
86
88
|
|
87
89
|
attribute_names = []
|
88
90
|
attributes.each do |attribute|
|
89
|
-
|
91
|
+
if !include_transient &&
|
92
|
+
transient_attributes.include?(attribute.name)
|
93
|
+
next
|
94
|
+
end
|
95
|
+
|
90
96
|
attribute_names << attribute.name
|
91
97
|
end
|
92
98
|
|
93
99
|
attribute_names
|
94
100
|
end
|
101
|
+
|
102
|
+
def all_attribute_names
|
103
|
+
attribute_names(include_transient: true)
|
104
|
+
end
|
95
105
|
end
|
96
106
|
|
97
107
|
class AttributeRegistry
|
@@ -151,24 +161,35 @@ module Schema
|
|
151
161
|
end
|
152
162
|
end
|
153
163
|
|
154
|
-
def attributes
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
end
|
164
|
+
def attributes(include_transient: nil)
|
165
|
+
include_transient ||= false
|
166
|
+
|
167
|
+
attribute_names = self.class.attribute_names(include_transient: include_transient)
|
159
168
|
|
160
|
-
data =
|
161
|
-
|
162
|
-
attributes[attribute.name] = public_send(attribute.name)
|
169
|
+
data = attribute_names.each_with_object({}) do |attribute_name, attributes|
|
170
|
+
attributes[attribute_name] = public_send(attribute_name)
|
163
171
|
end
|
164
172
|
|
165
173
|
transform_write(data)
|
166
174
|
|
167
175
|
data
|
168
176
|
end
|
169
|
-
|
177
|
+
|
178
|
+
def to_h
|
179
|
+
attributes
|
180
|
+
end
|
181
|
+
|
182
|
+
def all_attributes
|
183
|
+
attributes(include_transient: true)
|
184
|
+
end
|
170
185
|
|
171
186
|
def ==(other, attributes_names=nil, ignore_class: nil)
|
187
|
+
ignore_class ||= false
|
188
|
+
|
189
|
+
if not ignore_class
|
190
|
+
return false if self.class != other.class
|
191
|
+
end
|
192
|
+
|
172
193
|
comparison = Compare.(self, other, attributes_names)
|
173
194
|
|
174
195
|
different = comparison.different?(ignore_class: ignore_class)
|
@@ -50,12 +50,12 @@ module Schema
|
|
50
50
|
|
51
51
|
def self.build_entry(control_name, control, compare_name, compare)
|
52
52
|
control_class = control.class
|
53
|
-
if not control_class.
|
53
|
+
if not control_class.all_attribute_names.include?(control_name)
|
54
54
|
raise Error, "Attribute is not defined (Attribute Name: #{control_name.inspect}, Schema Class: #{control_class})"
|
55
55
|
end
|
56
56
|
|
57
57
|
compare_class = compare.class
|
58
|
-
if not compare_class.
|
58
|
+
if not compare_class.all_attribute_names.include?(compare_name)
|
59
59
|
raise Error, "Attribute is not defined (Attribute Name: #{compare_name.inspect}, Schema Class: #{compare_class})"
|
60
60
|
end
|
61
61
|
|
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.
|
4
|
+
version: 2.3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|
@@ -123,7 +123,7 @@ homepage: https://github.com/eventide-project/schema
|
|
123
123
|
licenses:
|
124
124
|
- MIT
|
125
125
|
metadata: {}
|
126
|
-
post_install_message:
|
126
|
+
post_install_message:
|
127
127
|
rdoc_options: []
|
128
128
|
require_paths:
|
129
129
|
- lib
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubygems_version: 3.1.2
|
142
|
-
signing_key:
|
142
|
+
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Primitives for schema and data structure
|
145
145
|
test_files: []
|