foobara 0.0.29 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb +2 -0
- data/projects/detached_entity/lib/foobara/detached_entity.rb +19 -0
- data/projects/{entity → detached_entity}/src/concerns/associations.rb +4 -59
- data/projects/detached_entity/src/concerns/equality.rb +24 -0
- data/projects/{entity → detached_entity}/src/concerns/primary_key.rb +2 -2
- data/projects/{entity → detached_entity}/src/concerns/reflection.rb +15 -1
- data/projects/detached_entity/src/concerns/types.rb +41 -0
- data/projects/detached_entity/src/detached_entity.rb +15 -0
- data/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/hash.rb +39 -0
- data/projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/attributes_declaration.rb +36 -0
- data/projects/detached_entity/src/extensions/builtin_types/detached_entity.rb +6 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/attributes_handler_desugarizer.rb +13 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/hash_desugarizer.rb +43 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/model_class_desugarizer.rb +21 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/primary_key_desugarizer.rb +19 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/to_type_transformer.rb +26 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb +35 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_present.rb +27 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_references_attribute.rb +36 -0
- data/projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration.rb +15 -0
- data/projects/entity/lib/foobara/entity.rb +3 -7
- data/projects/entity/src/concerns/attribute_helpers.rb +1 -58
- data/projects/entity/src/concerns/attributes.rb +1 -1
- data/projects/entity/src/concerns/callbacks.rb +1 -1
- data/projects/entity/src/concerns/initialization.rb +1 -1
- data/projects/entity/src/concerns/mutations.rb +68 -0
- data/projects/entity/src/concerns/persistence.rb +1 -1
- data/projects/entity/src/concerns/queries.rb +56 -1
- data/projects/entity/src/concerns/transactions.rb +1 -1
- data/projects/entity/src/concerns/types.rb +2 -18
- data/projects/entity/src/entity.rb +3 -48
- data/projects/entity/src/extensions/builtin_types/entity/casters/hash.rb +8 -20
- data/projects/entity/src/extensions/builtin_types/entity/validators/attributes_declaration.rb +3 -18
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/attributes_handler_desugarizer.rb +2 -3
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/hash_desugarizer.rb +2 -32
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/model_class_desugarizer.rb +2 -6
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/primary_key_desugarizer.rb +2 -11
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/to_type_transformer.rb +2 -11
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_is_symbol.rb +2 -27
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_present.rb +2 -19
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration/validate_primary_key_references_attribute.rb +3 -28
- data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration.rb +5 -1
- data/projects/entity/src/new_prepend.rb +1 -1
- data/projects/entity/src/not_found_error.rb +1 -1
- data/projects/foobara/lib/foobara/all.rb +1 -0
- data/projects/manifest/src/foobara/manifest/detached_entity.rb +30 -0
- data/projects/manifest/src/foobara/manifest/domain.rb +4 -0
- data/projects/manifest/src/foobara/manifest/entity.rb +3 -15
- data/projects/manifest/src/foobara/manifest/root_manifest.rb +8 -0
- data/projects/manifest/src/foobara/manifest/type.rb +17 -1
- data/projects/manifest/src/foobara/manifest/type_declaration.rb +17 -0
- data/projects/model/src/model.rb +3 -1
- data/projects/namespace/src/is_namespace.rb +6 -2
- data/projects/types/src/type.rb +0 -6
- metadata +24 -5
data/projects/entity/src/extensions/type_declarations/handlers/extend_entity_type_declaration.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
module Foobara
|
2
2
|
module TypeDeclarations
|
3
3
|
module Handlers
|
4
|
-
class ExtendEntityTypeDeclaration <
|
4
|
+
class ExtendEntityTypeDeclaration < ExtendDetachedEntityTypeDeclaration
|
5
5
|
def expected_type_symbol
|
6
6
|
:entity
|
7
7
|
end
|
8
|
+
|
9
|
+
def priority
|
10
|
+
super - 1
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "model"
|
2
|
+
|
3
|
+
module Foobara
|
4
|
+
module Manifest
|
5
|
+
class DetachedEntity < Model
|
6
|
+
# this isn't inherited? why not?
|
7
|
+
self.category_symbol = :type
|
8
|
+
|
9
|
+
optional_key(:associations, default: {})
|
10
|
+
|
11
|
+
alias detached_entity_manifest model_manifest
|
12
|
+
|
13
|
+
def primary_key_name
|
14
|
+
primary_key_attribute.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
def primary_key_type
|
18
|
+
@primary_key_type ||= TypeDeclaration.new(root_manifest, [*path, :primary_key_type])
|
19
|
+
end
|
20
|
+
|
21
|
+
def attribute_names
|
22
|
+
super - [primary_key_name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_detached_entity_name
|
26
|
+
full_model_name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,33 +2,21 @@ require_relative "model"
|
|
2
2
|
|
3
3
|
module Foobara
|
4
4
|
module Manifest
|
5
|
-
class Entity <
|
5
|
+
class Entity < DetachedEntity
|
6
|
+
# this isn't inherited? why not?
|
6
7
|
self.category_symbol = :type
|
7
8
|
|
8
|
-
optional_key(:associations, default: {})
|
9
|
-
|
10
9
|
alias entity_manifest model_manifest
|
11
10
|
|
12
11
|
def has_associations?
|
13
12
|
associations && !associations.empty?
|
14
13
|
end
|
15
14
|
|
16
|
-
def primary_key_name
|
17
|
-
primary_key_attribute.to_s
|
18
|
-
end
|
19
|
-
|
20
|
-
def primary_key_type
|
21
|
-
@primary_key_type ||= TypeDeclaration.new(root_manifest, [*path, :primary_key_type])
|
22
|
-
end
|
23
|
-
|
24
|
-
def attribute_names
|
25
|
-
super - [primary_key_name]
|
26
|
-
end
|
27
|
-
|
28
15
|
def full_entity_name
|
29
16
|
full_model_name
|
30
17
|
end
|
31
18
|
|
19
|
+
# TODO: should this instead be on DetachedEntity??
|
32
20
|
def associations
|
33
21
|
@associations ||= self[:associations].to_h do |path_key, type_name|
|
34
22
|
[path_key.to_sym, Type.new(root_manifest, [:type, type_name])]
|
@@ -45,6 +45,14 @@ module Foobara
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def detached_entity_by_name(name)
|
49
|
+
type = type_by_name(name)
|
50
|
+
|
51
|
+
raise "#{name} is not a detached entity" unless type.detached_entity?
|
52
|
+
|
53
|
+
type
|
54
|
+
end
|
55
|
+
|
48
56
|
def entity_by_name(name)
|
49
57
|
type = type_by_name(name)
|
50
58
|
|
@@ -11,6 +11,8 @@ module Foobara
|
|
11
11
|
if self == Type
|
12
12
|
if type.entity?
|
13
13
|
type = Entity.new(type.root_manifest, type.path)
|
14
|
+
elsif type.detached_entity?
|
15
|
+
type = DetachedEntity.new(type.root_manifest, type.path)
|
14
16
|
elsif type.model?
|
15
17
|
type = Model.new(type.root_manifest, type.path)
|
16
18
|
end
|
@@ -36,11 +38,25 @@ module Foobara
|
|
36
38
|
false
|
37
39
|
end
|
38
40
|
|
39
|
-
def
|
41
|
+
def detached_entity?
|
40
42
|
return false if reference == "entity"
|
41
43
|
|
42
44
|
type = base_type
|
43
45
|
|
46
|
+
while type
|
47
|
+
return true if type.reference.to_sym == :detached_entity
|
48
|
+
|
49
|
+
type = type.base_type
|
50
|
+
end
|
51
|
+
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
55
|
+
def model?
|
56
|
+
return false if reference == "entity" || reference == "detached_entity"
|
57
|
+
|
58
|
+
type = base_type
|
59
|
+
|
44
60
|
while type
|
45
61
|
return true if type.reference.to_sym == :model
|
46
62
|
|
@@ -91,6 +91,23 @@ module Foobara
|
|
91
91
|
type
|
92
92
|
end
|
93
93
|
|
94
|
+
def detached_entity?
|
95
|
+
return @detached_entity if defined?(@detached_entity)
|
96
|
+
|
97
|
+
@detached_entity = to_type.detached_entity?
|
98
|
+
end
|
99
|
+
|
100
|
+
def to_detached_entity
|
101
|
+
raise "not an detached_entity" unless detached_entity?
|
102
|
+
raise "detached_entity extension instead of an detached_entity" unless relevant_manifest.size == 1
|
103
|
+
|
104
|
+
type = to_type
|
105
|
+
|
106
|
+
raise "not an detached_entity" unless type.detached_entity?
|
107
|
+
|
108
|
+
type
|
109
|
+
end
|
110
|
+
|
94
111
|
def entity?
|
95
112
|
return @entity if defined?(@entity)
|
96
113
|
|
data/projects/model/src/model.rb
CHANGED
@@ -180,6 +180,8 @@ module Foobara
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
+
abstract
|
184
|
+
|
183
185
|
attr_accessor :mutable
|
184
186
|
|
185
187
|
def initialize(attributes = nil, options = {})
|
@@ -262,7 +264,7 @@ module Foobara
|
|
262
264
|
end
|
263
265
|
|
264
266
|
def read_attribute(attribute_name)
|
265
|
-
attributes[attribute_name
|
267
|
+
attributes[attribute_name&.to_sym]
|
266
268
|
end
|
267
269
|
|
268
270
|
def read_attribute!(attribute_name)
|
@@ -231,8 +231,12 @@ module Foobara
|
|
231
231
|
all
|
232
232
|
end
|
233
233
|
|
234
|
-
def foobara_registered?(...)
|
235
|
-
|
234
|
+
def foobara_registered?(path, ...)
|
235
|
+
if path.is_a?(Types::Type)
|
236
|
+
return false unless path.scoped_path_set?
|
237
|
+
end
|
238
|
+
|
239
|
+
!foobara_lookup(path, ...).nil?
|
236
240
|
end
|
237
241
|
|
238
242
|
def method_missing(method_name, *, **, &)
|
data/projects/types/src/type.rb
CHANGED
@@ -14,12 +14,6 @@ module Foobara
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
# TODO: needed/useful transformers/validators to implement:
|
18
|
-
#
|
19
|
-
# allow_empty (validation at attribute level)
|
20
|
-
# allow_nil (validation at attribute level)
|
21
|
-
# one_of (validation at attribute level)
|
22
|
-
|
23
17
|
attr_accessor :base_type,
|
24
18
|
:casters,
|
25
19
|
:transformers,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foobara-util
|
@@ -172,6 +172,25 @@ files:
|
|
172
172
|
- projects/concerns/src/concern.rb
|
173
173
|
- projects/delegate/lib/foobara/delegate.rb
|
174
174
|
- projects/delegate/src/extensions/module.rb
|
175
|
+
- projects/detached_entity/lib/foobara/detached_entity.rb
|
176
|
+
- projects/detached_entity/src/concerns/associations.rb
|
177
|
+
- projects/detached_entity/src/concerns/equality.rb
|
178
|
+
- projects/detached_entity/src/concerns/primary_key.rb
|
179
|
+
- projects/detached_entity/src/concerns/reflection.rb
|
180
|
+
- projects/detached_entity/src/concerns/types.rb
|
181
|
+
- projects/detached_entity/src/detached_entity.rb
|
182
|
+
- projects/detached_entity/src/extensions/builtin_types/detached_entity.rb
|
183
|
+
- projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/hash.rb
|
184
|
+
- projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/attributes_declaration.rb
|
185
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration.rb
|
186
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/attributes_handler_desugarizer.rb
|
187
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/hash_desugarizer.rb
|
188
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/model_class_desugarizer.rb
|
189
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/primary_key_desugarizer.rb
|
190
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/to_type_transformer.rb
|
191
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_is_symbol.rb
|
192
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_present.rb
|
193
|
+
- projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/validate_primary_key_references_attribute.rb
|
175
194
|
- projects/domain/lib/foobara/domain.rb
|
176
195
|
- projects/domain/src/domain.rb
|
177
196
|
- projects/domain/src/domain_mapper.rb
|
@@ -186,15 +205,13 @@ files:
|
|
186
205
|
- projects/domain/src/organization.rb
|
187
206
|
- projects/domain/src/organization_module_extension.rb
|
188
207
|
- projects/entity/lib/foobara/entity.rb
|
189
|
-
- projects/entity/src/concerns/associations.rb
|
190
208
|
- projects/entity/src/concerns/attribute_helpers.rb
|
191
209
|
- projects/entity/src/concerns/attributes.rb
|
192
210
|
- projects/entity/src/concerns/callbacks.rb
|
193
211
|
- projects/entity/src/concerns/initialization.rb
|
212
|
+
- projects/entity/src/concerns/mutations.rb
|
194
213
|
- projects/entity/src/concerns/persistence.rb
|
195
|
-
- projects/entity/src/concerns/primary_key.rb
|
196
214
|
- projects/entity/src/concerns/queries.rb
|
197
|
-
- projects/entity/src/concerns/reflection.rb
|
198
215
|
- projects/entity/src/concerns/transactions.rb
|
199
216
|
- projects/entity/src/concerns/types.rb
|
200
217
|
- projects/entity/src/entity.rb
|
@@ -226,6 +243,7 @@ files:
|
|
226
243
|
- projects/manifest/src/foobara/manifest/attributes.rb
|
227
244
|
- projects/manifest/src/foobara/manifest/base_manifest.rb
|
228
245
|
- projects/manifest/src/foobara/manifest/command.rb
|
246
|
+
- projects/manifest/src/foobara/manifest/detached_entity.rb
|
229
247
|
- projects/manifest/src/foobara/manifest/domain.rb
|
230
248
|
- projects/manifest/src/foobara/manifest/entity.rb
|
231
249
|
- projects/manifest/src/foobara/manifest/error.rb
|
@@ -373,6 +391,7 @@ require_paths:
|
|
373
391
|
- "./projects/common/lib"
|
374
392
|
- "./projects/concerns/lib"
|
375
393
|
- "./projects/delegate/lib"
|
394
|
+
- "./projects/detached_entity/lib"
|
376
395
|
- "./projects/domain/lib"
|
377
396
|
- "./projects/entity/lib"
|
378
397
|
- "./projects/enumerated/lib"
|