foobara 0.0.50 → 0.0.52
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/CHANGELOG.md +8 -0
- data/projects/command_connectors/src/serializers/success_serializer.rb +0 -1
- data/projects/detached_entity/src/concerns/aliases.rb +39 -0
- data/projects/detached_entity/src/concerns/associations.rb +4 -2
- data/projects/detached_entity/src/concerns/primary_key.rb +2 -2
- data/projects/detached_entity/src/concerns/reflection.rb +17 -28
- data/projects/detached_entity/src/concerns/serialize.rb +23 -0
- data/projects/detached_entity/src/detached_entity.rb +2 -0
- data/projects/model/src/concerns/aliases.rb +15 -0
- data/projects/model/src/concerns/reflection.rb +6 -6
- data/projects/model/src/concerns/types.rb +4 -0
- data/projects/model/src/model.rb +3 -2
- data/projects/types/src/type.rb +15 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f568d4dcdb081e50f321e36b9805621229ea6c48305cc5c15d5b352323015b
|
4
|
+
data.tar.gz: 4f4129cc01d8ef7cdb81c68f9a310641e022c5ca22ae2c394854e8053e46365c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8561097b379dbb98e1cc082fa6b1fb02f5d0b2cb1923c0b9360bd9e7a552cb484c305af77cde237a5fadebecdc518b75189885e01e2b2e8b7974f771ea738b9
|
7
|
+
data.tar.gz: 9568912e55c1c1593adf41143a5fd1f577d72b66e50ed69b4bf99ad4a00b3a1d048272187039904fade1a18032008547749f72fdf9b9ed8533a7fff7ffeeb998
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.52] - 2025-01-30
|
2
|
+
|
3
|
+
- Prefix and re-organize several model methods to facilitate type extension
|
4
|
+
|
5
|
+
## [0.0.51] - 2025-01-26
|
6
|
+
|
7
|
+
- Add a Type#remove_processor_by_symbol method to help with certain situations when defining custom types
|
8
|
+
|
1
9
|
## [0.0.50] - 2025-01-22
|
2
10
|
|
3
11
|
- Fill out more foobara_ model attribute helper methods to further support the ActiveRecordType gem
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Foobara
|
2
|
+
class DetachedEntity < Model
|
3
|
+
module Concerns
|
4
|
+
module Aliases
|
5
|
+
include Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def depends_on(...)
|
9
|
+
foobara_depends_on(...)
|
10
|
+
end
|
11
|
+
|
12
|
+
def deep_depends_on(...)
|
13
|
+
foobara_deep_depends_on(...)
|
14
|
+
end
|
15
|
+
|
16
|
+
def associations(...)
|
17
|
+
foobara_associations(...)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deep_associations(...)
|
21
|
+
foobara_deep_associations(...)
|
22
|
+
end
|
23
|
+
|
24
|
+
def attributes_type(...)
|
25
|
+
foobara_attributes_type(...)
|
26
|
+
end
|
27
|
+
|
28
|
+
def primary_key_attribute(...)
|
29
|
+
foobara_primary_key_attribute(...)
|
30
|
+
end
|
31
|
+
|
32
|
+
def model_name(...)
|
33
|
+
foobara_model_name(...)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -11,8 +11,8 @@ module Foobara
|
|
11
11
|
|
12
12
|
alias associations foobara_associations
|
13
13
|
|
14
|
-
def
|
15
|
-
@
|
14
|
+
def foobara_deep_associations
|
15
|
+
@foobara_deep_associations ||= begin
|
16
16
|
deep = {}
|
17
17
|
|
18
18
|
associations.each_pair do |data_path, type|
|
@@ -29,6 +29,8 @@ module Foobara
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
alias deep_associations foobara_deep_associations
|
33
|
+
|
32
34
|
# TODO: stamp this metadata out somewhere, preferably on deep_associations hash somehow
|
33
35
|
def association(name, *association_identifiers)
|
34
36
|
target_association_key = association_for(association_identifiers)
|
@@ -28,8 +28,8 @@ module Foobara
|
|
28
28
|
def foobara_primary_key_attribute
|
29
29
|
return @foobara_primary_key_attribute if @foobara_primary_key_attribute
|
30
30
|
|
31
|
-
|
32
|
-
@foobara_primary_key_attribute = superclass.
|
31
|
+
if superclass != DetachedEntity && superclass.respond_to?(:foobara_primary_key_attribute)
|
32
|
+
@foobara_primary_key_attribute = superclass.foobara_primary_key_attribute
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -2,29 +2,15 @@ module Foobara
|
|
2
2
|
class DetachedEntity < Model
|
3
3
|
module Concerns
|
4
4
|
module Reflection
|
5
|
-
class CannotConvertRecordWithoutPrimaryKeyToJsonError < StandardError; end
|
6
|
-
|
7
5
|
include Concern
|
8
6
|
|
9
|
-
def inspect
|
10
|
-
"<#{entity_name}:#{primary_key}>"
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_json(*_args)
|
14
|
-
primary_key&.to_json || raise(
|
15
|
-
CannotConvertRecordWithoutPrimaryKeyToJsonError,
|
16
|
-
"Cannot call record.to_json on unless record has a primary key. " \
|
17
|
-
"Consider instead calling record.attributes.to_json instead."
|
18
|
-
)
|
19
|
-
end
|
20
|
-
|
21
7
|
module ClassMethods
|
22
|
-
def
|
23
|
-
|
8
|
+
def foobara_depends_on
|
9
|
+
foobara_associations.values.map(&:target_class).uniq
|
24
10
|
end
|
25
11
|
|
26
|
-
def
|
27
|
-
types =
|
12
|
+
def foobara_deep_depends_on
|
13
|
+
types = foobara_deep_associations.sort_by do |path, _type|
|
28
14
|
[DataPath.new(path).path.size, path]
|
29
15
|
end.map(&:last)
|
30
16
|
|
@@ -32,29 +18,32 @@ module Foobara
|
|
32
18
|
end
|
33
19
|
|
34
20
|
def foobara_manifest(to_include: Set.new)
|
35
|
-
associations =
|
21
|
+
associations = foobara_associations.map do |(path, type)|
|
36
22
|
entity_class = type.target_class
|
37
|
-
entity_name = entity_class.
|
23
|
+
entity_name = entity_class.foobara_type.scoped_full_name
|
38
24
|
|
39
25
|
[path, entity_name]
|
40
26
|
end.sort.to_h
|
41
27
|
|
42
|
-
deep_associations =
|
28
|
+
deep_associations = foobara_deep_associations.map do |(path, type)|
|
43
29
|
entity_class = type.target_class
|
44
|
-
entity_name = entity_class.
|
30
|
+
entity_name = entity_class.foobara_type.scoped_full_name
|
45
31
|
|
46
32
|
[path, entity_name]
|
47
33
|
end.sort.to_h
|
48
34
|
|
49
|
-
|
35
|
+
base_manifest = superclass.respond_to?(:foobara_manifest) ? super : {}
|
36
|
+
|
37
|
+
base_manifest.merge(
|
50
38
|
Util.remove_blank(
|
51
|
-
depends_on:
|
52
|
-
deep_depends_on:
|
39
|
+
depends_on: foobara_depends_on.map(&:full_entity_name),
|
40
|
+
deep_depends_on: foobara_deep_depends_on.map(&:full_entity_name),
|
53
41
|
associations:,
|
54
42
|
deep_associations:,
|
55
|
-
entity_name
|
56
|
-
primary_key_attribute
|
57
|
-
primary_key_type:
|
43
|
+
entity_name: foobara_model_name,
|
44
|
+
primary_key_attribute: foobara_primary_key_attribute,
|
45
|
+
primary_key_type:
|
46
|
+
foobara_attributes_type.declaration_data[:element_type_declarations][foobara_primary_key_attribute]
|
58
47
|
)
|
59
48
|
)
|
60
49
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Foobara
|
2
|
+
class DetachedEntity < Model
|
3
|
+
module Concerns
|
4
|
+
module Serialize
|
5
|
+
class CannotConvertRecordWithoutPrimaryKeyToJsonError < StandardError; end
|
6
|
+
|
7
|
+
include Concern
|
8
|
+
|
9
|
+
def inspect
|
10
|
+
"<#{entity_name}:#{primary_key}>"
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_json(*_args)
|
14
|
+
primary_key&.to_json || raise(
|
15
|
+
CannotConvertRecordWithoutPrimaryKeyToJsonError,
|
16
|
+
"Cannot call record.to_json on unless record has a primary key. " \
|
17
|
+
"Consider instead calling record.attributes.to_json instead."
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -7,12 +7,12 @@ module Foobara
|
|
7
7
|
module ClassMethods
|
8
8
|
def foobara_manifest(to_include: Set.new)
|
9
9
|
Util.remove_blank(
|
10
|
-
attributes_type:
|
11
|
-
organization_name
|
12
|
-
domain_name
|
13
|
-
model_name
|
14
|
-
model_base_class:
|
15
|
-
model_class:
|
10
|
+
attributes_type: foobara_attributes_type.declaration_data,
|
11
|
+
organization_name: foobara_type.foobara_domain.foobara_organization_name,
|
12
|
+
domain_name: foobara_type.foobara_domain.foobara_domain_name,
|
13
|
+
model_name: foobara_model_name,
|
14
|
+
model_base_class: foobara_type.declaration_data[:model_base_class],
|
15
|
+
model_class: foobara_type.declaration_data[:model_class]
|
16
16
|
)
|
17
17
|
end
|
18
18
|
end
|
data/projects/model/src/model.rb
CHANGED
@@ -8,6 +8,7 @@ module Foobara
|
|
8
8
|
|
9
9
|
include Concerns::Types
|
10
10
|
include Concerns::Reflection
|
11
|
+
include Concerns::Aliases
|
11
12
|
|
12
13
|
class << self
|
13
14
|
attr_accessor :is_abstract
|
@@ -84,8 +85,8 @@ module Foobara
|
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
87
|
-
def
|
88
|
-
|
88
|
+
def foobara_model_name
|
89
|
+
foobara_type&.scoped_name || Util.non_full_name(self)
|
89
90
|
rescue Foobara::Scoped::NoScopedPathSetError
|
90
91
|
# :nocov:
|
91
92
|
Util.non_full_name(self)
|
data/projects/types/src/type.rb
CHANGED
@@ -101,6 +101,21 @@ module Foobara
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
def remove_processor_by_symbol(symbol)
|
105
|
+
[
|
106
|
+
casters,
|
107
|
+
element_processors,
|
108
|
+
processor_classes_requiring_type,
|
109
|
+
processors,
|
110
|
+
transformers,
|
111
|
+
validators
|
112
|
+
].each do |processor_collection|
|
113
|
+
processor_collection&.delete_if { |p| p.symbol == symbol }
|
114
|
+
end
|
115
|
+
supported_processor_classes&.each { |processor_hash| processor_hash.delete(symbol) }
|
116
|
+
processor_classes_requiring_type&.delete_if { |p| p.symbol == symbol }
|
117
|
+
end
|
118
|
+
|
104
119
|
def each_processor_class_requiring_type(&block)
|
105
120
|
base_type&.each_processor_class_requiring_type(&block)
|
106
121
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
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.52
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bigdecimal
|
@@ -186,10 +186,12 @@ files:
|
|
186
186
|
- projects/delegate/lib/foobara/delegate.rb
|
187
187
|
- projects/delegate/src/extensions/module.rb
|
188
188
|
- projects/detached_entity/lib/foobara/detached_entity.rb
|
189
|
+
- projects/detached_entity/src/concerns/aliases.rb
|
189
190
|
- projects/detached_entity/src/concerns/associations.rb
|
190
191
|
- projects/detached_entity/src/concerns/equality.rb
|
191
192
|
- projects/detached_entity/src/concerns/primary_key.rb
|
192
193
|
- projects/detached_entity/src/concerns/reflection.rb
|
194
|
+
- projects/detached_entity/src/concerns/serialize.rb
|
193
195
|
- projects/detached_entity/src/concerns/types.rb
|
194
196
|
- projects/detached_entity/src/detached_entity.rb
|
195
197
|
- projects/detached_entity/src/extensions/builtin_types/detached_entity.rb
|
@@ -270,6 +272,7 @@ files:
|
|
270
272
|
- projects/manifest/src/foobara/manifest/type.rb
|
271
273
|
- projects/manifest/src/foobara/manifest/type_declaration.rb
|
272
274
|
- projects/model/lib/foobara/model.rb
|
275
|
+
- projects/model/src/concerns/aliases.rb
|
273
276
|
- projects/model/src/concerns/reflection.rb
|
274
277
|
- projects/model/src/concerns/types.rb
|
275
278
|
- projects/model/src/extensions/builtin_types/model/casters/hash.rb
|
@@ -438,7 +441,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
438
441
|
- !ruby/object:Gem::Version
|
439
442
|
version: '0'
|
440
443
|
requirements: []
|
441
|
-
rubygems_version: 3.6.
|
444
|
+
rubygems_version: 3.6.3
|
442
445
|
specification_version: 4
|
443
446
|
summary: A command-centric and discoverable software framework with a focus on domain
|
444
447
|
concepts and abstracting away integration code
|