evt-schema 2.2.5.0 → 2.2.7.2
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/schema.rb +14 -5
- data/lib/schema/data_structure.rb +12 -1
- data/lib/schema/fixtures +1 -0
- data/lib/schema/fixtures.rb +1 -0
- data/lib/schema/schema.rb +13 -3
- data/lib/schema/schema/compare/comparison.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba3db2edbbe435d203deacf8e1adf8371126f4233496668a4a3bf64e0f9b7b9
|
4
|
+
data.tar.gz: 327690e6aac9bf21458776935ab4213d62b45bf109290bcb416ac18fea0912de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7244b65f846380ea41de0f6b19ed6c1bac4b67ca7843e6e0ea20903627904c58879a3d703f4cd5f35caa23e4b5569cb8a7948523ea18bba02d5cf304ed6f6b06
|
7
|
+
data.tar.gz: 8d7418966296aa94c6df0bc79abc30b8d2e06e8cdd46bcc8a65f20fbd92052b1d763a0596951011aaaaf10273931b9f4082cbb8972381aedbfe86a446b3192a9
|
@@ -124,11 +124,20 @@ module Schema
|
|
124
124
|
attribute :some_other_attribute
|
125
125
|
end
|
126
126
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
127
|
+
class Primitive
|
128
|
+
include ::Schema
|
129
|
+
attribute :some_attribute, default: 11
|
130
|
+
attribute :some_other_attribute
|
131
|
+
end
|
132
|
+
|
133
|
+
class Proc
|
134
|
+
include ::Schema
|
135
|
+
attribute :some_attribute, default: proc { 'some default value' }
|
136
|
+
end
|
137
|
+
|
138
|
+
class ObjectReference
|
139
|
+
include ::Schema
|
140
|
+
attribute :some_attribute, default: []
|
132
141
|
end
|
133
142
|
end
|
134
143
|
|
@@ -39,9 +39,20 @@ module Schema
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def deep_copy
|
43
43
|
data = to_h
|
44
44
|
self.class.build(data)
|
45
45
|
end
|
46
|
+
alias :dup :deep_copy
|
47
|
+
|
48
|
+
def clone
|
49
|
+
duplicate = deep_copy
|
50
|
+
|
51
|
+
if frozen?
|
52
|
+
duplicate.freeze
|
53
|
+
end
|
54
|
+
|
55
|
+
duplicate
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
data/lib/schema/fixtures
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/schema/Users/sbellware/projects/eventide/schema-fixtures/lib/schema/fixtures
|
@@ -0,0 +1 @@
|
|
1
|
+
lib/schema/Users/sbellware/projects/eventide/schema-fixtures/lib/schema/fixtures.rb
|
data/lib/schema/schema.rb
CHANGED
@@ -62,7 +62,7 @@ module Schema
|
|
62
62
|
if default.is_a? Proc
|
63
63
|
initialize_value = default
|
64
64
|
elsif !default.nil?
|
65
|
-
initialize_value = proc { default }
|
65
|
+
initialize_value = proc { default.clone }
|
66
66
|
end
|
67
67
|
|
68
68
|
::Attribute::Define.(self, attribute_name, :accessor, check: check, &initialize_value)
|
@@ -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
|
@@ -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.2.
|
4
|
+
version: 2.2.7.2
|
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: 2020-07-
|
11
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|
@@ -110,6 +110,8 @@ files:
|
|
110
110
|
- lib/schema/controls/schema.rb
|
111
111
|
- lib/schema/controls/schema/different.rb
|
112
112
|
- lib/schema/data_structure.rb
|
113
|
+
- lib/schema/fixtures
|
114
|
+
- lib/schema/fixtures.rb
|
113
115
|
- lib/schema/schema.rb
|
114
116
|
- lib/schema/schema/attribute.rb
|
115
117
|
- lib/schema/schema/compare.rb
|