uinit-structure 0.1.4 → 0.1.5
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/uinit/structure/attribute.rb +3 -1
- data/lib/uinit/structure/attribute_builder.rb +7 -1
- data/lib/uinit/structure/compilers/as_json.rb +1 -1
- data/lib/uinit/structure/compilers/attribute.rb +1 -1
- data/lib/uinit/structure/compilers/constructor.rb +2 -4
- data/lib/uinit/structure/version.rb +1 -1
- data/lib/uinit/structure.rb +2 -2
- 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: 3931923313a282612e428ab5de5c935a7cc949dde0e3ba3e2a5d0af52480974e
|
4
|
+
data.tar.gz: 7adabb1c170af08c1cc5ba9eec5ceb4efab1fd3c4fce899d491e7fd9226bda20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3797d78ad3a31326fd5d50e1019ff53f0126a312c6978461471b354db1182c9c547a085601be1612d57e23d3e35bcda87cdfb0c4ef3fd32da1489ccc18809414
|
7
|
+
data.tar.gz: 491603d0e62cf0901df9adfdae267437557055f628702a9c73786a2a330b0468c74299b66b0b0cfa1154479e64320be7cdf066cdfc607457722e0ddeab0824ad
|
@@ -91,9 +91,11 @@ module Uinit
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def optional?
|
94
|
-
@default != UNDEFINED
|
94
|
+
defined?(@optional) ? @optional : @default != UNDEFINED
|
95
95
|
end
|
96
96
|
|
97
|
+
attr_writer :optional
|
98
|
+
|
97
99
|
def init=(val)
|
98
100
|
raise ArgumentError, 'init must be a boolean' unless [true, false].include?(val)
|
99
101
|
|
@@ -70,12 +70,18 @@ module Uinit
|
|
70
70
|
self
|
71
71
|
end
|
72
72
|
|
73
|
-
def optional(val)
|
73
|
+
def optional(val = true)
|
74
74
|
attribute.optional = val
|
75
75
|
|
76
76
|
self
|
77
77
|
end
|
78
78
|
|
79
|
+
def required
|
80
|
+
attribute.optional = false
|
81
|
+
|
82
|
+
self
|
83
|
+
end
|
84
|
+
|
79
85
|
def init(val)
|
80
86
|
attribute.init = val
|
81
87
|
|
@@ -30,9 +30,7 @@ module Uinit
|
|
30
30
|
end
|
31
31
|
|
32
32
|
<<~RUBY
|
33
|
-
|
34
|
-
super(hsh)
|
35
|
-
end
|
33
|
+
super(hsh)
|
36
34
|
RUBY
|
37
35
|
end
|
38
36
|
|
@@ -75,7 +73,7 @@ module Uinit
|
|
75
73
|
|
76
74
|
def compile_default_attribute(name, attribute)
|
77
75
|
<<~RUBY
|
78
|
-
self.#{name} =
|
76
|
+
self.#{name} = __structure_schema.#{name}.default#{attribute.default.is_a?(Proc) ? '.call' : ''}
|
79
77
|
RUBY
|
80
78
|
end
|
81
79
|
end
|
data/lib/uinit/structure.rb
CHANGED
@@ -70,7 +70,7 @@ module Uinit
|
|
70
70
|
attr_writer :attributes, :attributes_scope
|
71
71
|
end
|
72
72
|
|
73
|
-
memo def
|
74
|
-
memo def
|
73
|
+
memo def __structure_schema = self.class.structure_schema
|
74
|
+
memo def __attributes = self.class.attributes
|
75
75
|
end
|
76
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uinit-structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kimoja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|