evt-schema 2.3.1.6 → 2.4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d2604faa3a43356561c9c0ccaf6ef63550d3351d79a6f4f032acf62b4ebb6d0
4
- data.tar.gz: 4e93fb8a36bb8fb3de0220c08450b56254a14ef3447ea242a9d09774e4bb3ba0
3
+ metadata.gz: 35387bf895aaceee0a8b592ba686dd1cdc24448c8bca10d7e7714f0ff55387b4
4
+ data.tar.gz: 8d60be6f2a80644f3fb6517d72c5d10842fc399386d509aeeb19cf051e99a61d
5
5
  SHA512:
6
- metadata.gz: 4d6b5342a2df666e0fcbe3e1d3c25afd67a2854b1f1e46c02fc836c92f94568e3df6a9da492dd0d8f50ef4b4b0c6393175056aba8bb8ed2faa07d1115cd926df
7
- data.tar.gz: 6bd8e4673db5859e8b29a2b587afe94a1faf55966c52683f5d5e3a64ee18f0ebb036eff3516a48a385988e1e18ca8645955023ebdf1d42a236e54aceeaba564c
6
+ metadata.gz: 712f0cc9e56c0d053226a21375336c16664b02ff8a77df029c32c01ad75c38bc02ce57bb3bcfef91ed93701a1c04e117ecb885d2da3e2e4b2da1ced3d5786cef
7
+ data.tar.gz: 5e403e19b077b933fc0d22783679ba3673e5afa8decc9e82dcb8d9f555222ab568241bfac3e5df6615e44d97ff1aedfb2975e0d5af6786536c76da04a4deb876
@@ -119,25 +119,9 @@ module Schema
119
119
  end
120
120
 
121
121
  class Example
122
- include ::Schema
123
- attribute :some_attribute, default: 'some default value'
124
- attribute :some_other_attribute
125
- end
126
-
127
- class Primitive
128
- include ::Schema
129
- attribute :some_attribute, default: 11
130
- attribute :some_other_attribute
131
- end
132
-
133
- class Proc
134
122
  include ::Schema
135
123
  attribute :some_attribute, default: proc { 'some default value' }
136
- end
137
-
138
- class ObjectReference
139
- include ::Schema
140
- attribute :some_attribute, default: []
124
+ attribute :some_other_attribute
141
125
  end
142
126
  end
143
127
 
data/lib/schema/schema.rb CHANGED
@@ -62,11 +62,12 @@ module Schema
62
62
  end
63
63
  end
64
64
 
65
- initialize_value = nil
66
- if default.is_a? Proc
65
+ if default.nil?
66
+ initialize_value = nil
67
+ elsif default.respond_to?(:call)
67
68
  initialize_value = default
68
- elsif !default.nil?
69
- initialize_value = proc { default.clone }
69
+ else
70
+ raise Schema::Attribute::Error, "Default values must be callable, like procs, lambdas, or objects that respond to the call method (Attribute: #{attribute_name})"
70
71
  end
71
72
 
72
73
  ::Attribute::Define.(self, attribute_name, :accessor, check: check, &initialize_value)
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.1.6
4
+ version: 2.4.0.0
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: 2024-04-21 00:00:00.000000000 Z
11
+ date: 2024-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-attribute
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  - !ruby/object:Gem::Version
137
137
  version: '0'
138
138
  requirements: []
139
- rubygems_version: 3.4.10
139
+ rubygems_version: 3.5.9
140
140
  signing_key:
141
141
  specification_version: 4
142
142
  summary: Primitives for schema and data structure