foobara 0.0.134 → 0.0.136

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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/projects/callback/src/registry/chained_conditioned.rb +1 -3
  4. data/projects/callback/src/registry/joined_conditioned.rb +28 -0
  5. data/projects/command/src/command_pattern_implementation/concerns/callbacks.rb +63 -46
  6. data/projects/command/src/command_pattern_implementation/concerns/state_machine.rb +10 -1
  7. data/projects/command_connectors/lib/foobara/command_connectors.rb +1 -1
  8. data/projects/command_connectors/src/command_connector.rb +1 -1
  9. data/projects/command_connectors/src/transformed_command.rb +0 -2
  10. data/projects/command_connectors/src/transformers/load_aggregates_pre_commit_transformer.rb +4 -21
  11. data/projects/command_connectors/src/transformers/load_aggregates_transformer.rb +30 -0
  12. data/projects/command_connectors/src/transformers/load_atoms_pre_commit_transformer.rb +4 -22
  13. data/projects/command_connectors/src/transformers/load_atoms_transformer.rb +31 -0
  14. data/projects/common/src/error.rb +4 -0
  15. data/projects/common/src/error_key.rb +1 -1
  16. data/projects/domain/src/domain_module_extension.rb +0 -1
  17. data/projects/domain/src/organization.rb +0 -1
  18. data/projects/entity/lib/foobara/entity.rb +1 -1
  19. data/projects/entity/src/association_depth.rb +7 -0
  20. data/projects/foobara/lib/foobara/all.rb +36 -32
  21. data/projects/foobara/lib/foobara.rb +1 -0
  22. data/projects/foobara/src/foobara.rb +62 -0
  23. data/projects/foobara/src/project.rb +48 -0
  24. data/projects/manifest/src/foobara/manifest/possible_error.rb +0 -2
  25. data/projects/model/src/model.rb +0 -3
  26. data/projects/namespace/src/namespace.rb +0 -1
  27. metadata +7 -4
  28. data/projects/monorepo/lib/foobara/monorepo/project.rb +0 -54
  29. data/projects/monorepo/lib/foobara/monorepo.rb +0 -63
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7741d716521ec606a818e81e6fdca39b26b4a42d2d2d2de64ecf1078d67a2db2
4
- data.tar.gz: b9c1c9e51c08155b848c56eed519302c2722fc84e0baba61d677f21ce3c0f7a9
3
+ metadata.gz: 6f944c52f318016bd2742fb96208d11a2647d4802ee0a1ac4fbb5b353c5d6ad4
4
+ data.tar.gz: 5c7560766afe430188cd41053ce9f470eae20605dba8dde824432b760e6aa336
5
5
  SHA512:
6
- metadata.gz: 732828b89b9a9bfc01226f89f83f1087a010e8f72ee71f5f49a2cd4942f12c22e506d3f228488f408bee41c4f43bb9737e3fb94fd5b39904230271ce8d9ab38c
7
- data.tar.gz: 2cdb0f651548752a8ba603a2d6d25caea56deb6c3fc662583a533831bcfe607b9334e438333b590face7b6ee3f3f62d7e633bebb8e7feba25288c5d6b6f8ff60
6
+ metadata.gz: 3bf5da1d2282282a3d17eb44a0f8ca815c525800f71de56a05ed1c1b66babf5662293a0549df8a2ba6ee88da6cca7fe334f7a852d82b010afcf05f6d21ba1541
7
+ data.tar.gz: 1444d194eaa3389270cdd23422ec294a59f523e1a71291a92551951987b54c7e316ce724465f7d0fa1151e5c7c2bad84879435eac2908c402f1c3ee888224c5f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [0.0.136] - 2025-07-06
2
+
3
+ - Do not allow calling Foobara.reset_alls in production
4
+ - Fix an error backtrace bug
5
+ - Separate Atom/Aggregate request versus object behavior in precommit transformers
6
+ - Fix busted command-class-level state machine callbacks
7
+
8
+ # [0.0.135] - 2025-07-01
9
+
10
+ - Eliminate Monorepo project
11
+
1
12
  # [0.0.134] - 2025-06-27
2
13
 
3
14
  - Add LoadAtomsPreCommitTransformer
@@ -1,4 +1,4 @@
1
- Foobara.require_project_file("callback", "registry/conditioned")
1
+ require_relative "joined_conditioned"
2
2
 
3
3
  module Foobara
4
4
  module Callback
@@ -6,8 +6,6 @@ module Foobara
6
6
  class ChainedConditioned < Conditioned
7
7
  attr_accessor :other_conditions_registry
8
8
 
9
- class InvalidConditions < StandardError; end
10
-
11
9
  foobara_delegate :possible_conditions, :possible_condition_keys, to: :other_conditions_registry
12
10
 
13
11
  def initialize(other_conditions_registry)
@@ -0,0 +1,28 @@
1
+ require_relative "conditioned"
2
+
3
+ module Foobara
4
+ module Callback
5
+ module Registry
6
+ class JoinedConditioned < Conditioned
7
+ attr_accessor :first, :second
8
+
9
+ foobara_delegate :possible_conditions, :possible_condition_keys, to: :first
10
+
11
+ def initialize(first, second)
12
+ self.first = first
13
+ self.second = second
14
+
15
+ super(possible_conditions)
16
+ end
17
+
18
+ def unioned_callback_set_for(...)
19
+ super.union(
20
+ first.unioned_callback_set_for(...).union(
21
+ second.unioned_callback_set_for(...)
22
+ )
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,5 @@
1
+ require_relative "../../state_machine"
2
+
1
3
  module Foobara
2
4
  module CommandPatternImplementation
3
5
  module Concerns
@@ -17,75 +19,90 @@ module Foobara
17
19
  subclass_defined_callbacks.register_callback(:after, &)
18
20
  end
19
21
 
20
- def callback_state_machine_target
21
- Foobara::Command::StateMachine
22
+ def state_machine_callback_registry
23
+ return @state_machine_callback_registry if defined?(@state_machine_callback_registry)
24
+
25
+ @state_machine_callback_registry = if superclass.respond_to?(:state_machine_callback_registry)
26
+ Callback::Registry::ChainedConditioned.new(
27
+ superclass.state_machine_callback_registry
28
+ )
29
+ else
30
+ Callback::Registry::Conditioned.new(
31
+ from: Foobara::Command::StateMachine.states,
32
+ transition: Foobara::Command::StateMachine.transitions,
33
+ to: Foobara::Command::StateMachine.states
34
+ )
35
+ end
22
36
  end
23
37
 
24
- foobara_delegate :remove_all_callbacks, to: :callback_state_machine_target
38
+ def remove_all_callbacks
39
+ Foobara::Command::StateMachine.remove_all_callbacks
40
+ if defined?(@state_machine_callback_registry)
41
+ remove_instance_variable(:@state_machine_callback_registry)
42
+ end
43
+ end
25
44
  end
26
45
 
27
- on_include do
28
- self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
29
-
30
- [self, singleton_class].each do |target|
31
- [:before, :after].each do |type|
32
- target.define_method "#{type}_any_transition" do |&block|
33
- callback_state_machine_target.register_transition_callback(type) do |state_machine:, **args|
34
- block.call(command: state_machine.owner, **args)
35
- end
46
+ [self, ClassMethods].each do |target|
47
+ [:before, :after].each do |type|
48
+ target.define_method "#{type}_any_transition" do |&block|
49
+ state_machine_callback_registry.register_callback(type) do |state_machine:, **args|
50
+ block.call(command: state_machine.owner, **args)
36
51
  end
37
52
  end
53
+ end
38
54
 
39
- target.define_method "around_any_transition" do |&block|
40
- callback_state_machine_target.register_transition_callback(
41
- :around
42
- ) do |state_machine:, **args, &do_transition_block|
43
- block.call(command: state_machine.owner, **args, &do_transition_block)
44
- end
55
+ target.define_method "around_any_transition" do |&block|
56
+ state_machine_callback_registry.register_callback(
57
+ :around
58
+ ) do |state_machine:, **args, &do_transition_block|
59
+ block.call(command: state_machine.owner, **args, &do_transition_block)
45
60
  end
61
+ end
46
62
 
47
- target.define_method :error_any_transition do |&block|
48
- callback_state_machine_target.register_transition_callback(:error) do |error|
49
- callback_data = error.callback_data
63
+ target.define_method :error_any_transition do |&block|
64
+ state_machine_callback_registry.register_callback(:error) do |error|
65
+ callback_data = error.callback_data
50
66
 
51
- state_machine = callback_data[:state_machine]
52
- command = state_machine.owner
53
- from = callback_data[:from]
54
- transition = callback_data[:transition]
55
- to = callback_data[:to]
67
+ state_machine = callback_data[:state_machine]
68
+ command = state_machine.owner
69
+ from = callback_data[:from]
70
+ transition = callback_data[:transition]
71
+ to = callback_data[:to]
56
72
 
57
- block.call(error:, command:, state_machine:, from:, to:, transition:)
58
- end
73
+ block.call(error:, command:, state_machine:, from:, to:, transition:)
59
74
  end
60
75
  end
76
+ end
61
77
 
62
- Foobara::Command::StateMachine.transitions.each do |transition|
63
- [self, singleton_class].each do |target|
64
- [:before, :after].each do |type|
65
- target.define_method "#{type}_#{transition}" do |&block|
66
- callback_state_machine_target.register_transition_callback(
67
- type, transition:
68
- ) do |state_machine:, **args|
69
- block.call(command: state_machine.owner, **args)
70
- end
78
+ Foobara::Command::StateMachine.transitions.each do |transition|
79
+ [self, ClassMethods].each do |target|
80
+ [:before, :after].each do |type|
81
+ target.define_method "#{type}_#{transition}" do |&block|
82
+ state_machine_callback_registry.register_callback(
83
+ type, transition:
84
+ ) do |state_machine:, **args|
85
+ block.call(command: state_machine.owner, **args)
71
86
  end
72
87
  end
88
+ end
73
89
 
74
- target.define_method "around_#{transition}" do |&block|
75
- callback_state_machine_target.register_transition_callback(
76
- :around, transition:
77
- ) do |state_machine:, **args, &do_transition_block|
78
- block.call(command: state_machine.owner, **args, &do_transition_block)
79
- end
90
+ target.define_method "around_#{transition}" do |&block|
91
+ state_machine_callback_registry.register_callback(
92
+ :around, transition:
93
+ ) do |state_machine:, **args, &do_transition_block|
94
+ block.call(command: state_machine.owner, **args, &do_transition_block)
80
95
  end
81
96
  end
82
97
  end
83
98
  end
84
99
 
85
- private
100
+ def state_machine_callback_registry
101
+ state_machine.callback_registry
102
+ end
86
103
 
87
- def callback_state_machine_target
88
- state_machine
104
+ on_include do
105
+ self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
89
106
  end
90
107
  end
91
108
  end
@@ -3,8 +3,17 @@ module Foobara
3
3
  module Concerns
4
4
  module StateMachine
5
5
  def state_machine
6
+ return @state_machine if defined?(@state_machine)
7
+
6
8
  # It makes me nervous to pass self around. Seems like a design smell.
7
- @state_machine ||= Foobara::Command::StateMachine.new(owner: self)
9
+ @state_machine = Foobara::Command::StateMachine.new(owner: self)
10
+
11
+ @state_machine.callback_registry = Callback::Registry::JoinedConditioned.new(
12
+ @state_machine.callback_registry,
13
+ self.class.state_machine_callback_registry
14
+ )
15
+
16
+ @state_machine
8
17
  end
9
18
  end
10
19
  end
@@ -30,5 +30,5 @@ module Foobara
30
30
  end
31
31
  end
32
32
 
33
- Monorepo.project "command_connectors"
33
+ project "command_connectors"
34
34
  end
@@ -303,7 +303,7 @@ module Foobara
303
303
  end
304
304
 
305
305
  def connect_delayed(registerable_name, *args, **opts)
306
- delayed_connections[registerable_name] = { args:, opts: }
306
+ delayed_connections[registerable_name.to_s] = { args:, opts: }
307
307
  end
308
308
 
309
309
  def delayed_connections
@@ -1,6 +1,5 @@
1
1
  module Foobara
2
2
  # TODO: feels so strange that this doesn't inherit from command
3
- # TODO: move this to command connectors project
4
3
  class TransformedCommand
5
4
  class << self
6
5
  # TODO: handle errors_transformers!
@@ -752,7 +751,6 @@ module Foobara
752
751
  self.outcome = outcome if outcome
753
752
  rescue => e
754
753
  if capture_unknown_error
755
- # TODO: move to superclass?
756
754
  self.outcome = Outcome.error(CommandConnector::UnknownError.for(e))
757
755
  else
758
756
  # :nocov:
@@ -1,35 +1,18 @@
1
+ require_relative "load_aggregates_transformer"
2
+
1
3
  module Foobara
2
4
  module CommandConnectors
3
5
  module Transformers
4
- class LoadAggregatesPreCommitTransformer < Value::Transformer
6
+ class LoadAggregatesPreCommitTransformer < LoadAggregatesTransformer
5
7
  def applicable?(request)
6
8
  request.command.outcome.success?
7
9
  end
8
10
 
9
11
  def transform(request)
10
- load_aggregates(request.command.outcome.result)
12
+ super(request.command.outcome.result)
11
13
 
12
14
  request
13
15
  end
14
-
15
- def load_aggregates(object)
16
- case object
17
- when Entity
18
- object.class.load_aggregate(object)
19
- when Array
20
- object.each do |element|
21
- load_aggregates(element)
22
- end
23
- when Hash
24
- object.each_key do |key|
25
- load_aggregates(key)
26
- end
27
-
28
- object.each_value do |value|
29
- load_aggregates(value)
30
- end
31
- end
32
- end
33
16
  end
34
17
  end
35
18
  end
@@ -0,0 +1,30 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ module Transformers
4
+ class LoadAggregatesTransformer < Value::Transformer
5
+ def transform(object)
6
+ load_aggregates(object)
7
+ end
8
+
9
+ def load_aggregates(object)
10
+ case object
11
+ when Entity
12
+ object.class.load_aggregate(object)
13
+ when Array
14
+ object.each do |element|
15
+ load_aggregates(element)
16
+ end
17
+ when Hash
18
+ object.each_key do |key|
19
+ load_aggregates(key)
20
+ end
21
+
22
+ object.each_value do |value|
23
+ load_aggregates(value)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,36 +1,18 @@
1
+ require_relative "load_atoms_transformer"
2
+
1
3
  module Foobara
2
4
  module CommandConnectors
3
5
  module Transformers
4
- class LoadAtomsPreCommitTransformer < Value::Transformer
6
+ class LoadAtomsPreCommitTransformer < LoadAtomsTransformer
5
7
  def applicable?(request)
6
8
  request.command.outcome.success?
7
9
  end
8
10
 
9
11
  def transform(request)
10
- load_atoms(request.command.outcome.result)
12
+ super(request.command.outcome.result)
11
13
 
12
14
  request
13
15
  end
14
-
15
- def load_atoms(object)
16
- case object
17
- when Entity
18
- if object.persisted? && !object.loaded?
19
- object.class.load(object)
20
- end
21
- when Model
22
- load_atoms(object.attributes)
23
- when Array
24
- object.each do |element|
25
- load_atoms(element)
26
- end
27
- when Hash
28
- object.each_pair do |key, value|
29
- load_atoms(key)
30
- load_atoms(value)
31
- end
32
- end
33
- end
34
16
  end
35
17
  end
36
18
  end
@@ -0,0 +1,31 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ module Transformers
4
+ class LoadAtomsTransformer < Value::Transformer
5
+ def transform(object)
6
+ load_atoms(object)
7
+ end
8
+
9
+ def load_atoms(object)
10
+ case object
11
+ when Entity
12
+ if object.persisted? && !object.loaded?
13
+ object.class.load(object)
14
+ end
15
+ when Model
16
+ load_atoms(object.attributes)
17
+ when Array
18
+ object.each do |element|
19
+ load_atoms(element)
20
+ end
21
+ when Hash
22
+ object.each_pair do |key, value|
23
+ load_atoms(key)
24
+ load_atoms(value)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -231,6 +231,10 @@ module Foobara
231
231
  has_build_error = false
232
232
 
233
233
  1.upto(10) do |i|
234
+ backtrace_line = backtrace_when_initialized[i]
235
+
236
+ break unless backtrace_line
237
+
234
238
  if backtrace_when_initialized[i].end_with?("#build_error'")
235
239
  index = i + 1
236
240
  has_build_error = true
@@ -1,5 +1,5 @@
1
1
  module Foobara
2
- # TODO: path's have use outside of errors. Make this more general.
2
+ # TODO: paths have use outside of errors. Make this more general.
3
3
  class ErrorKey
4
4
  # TODO: use this wherever it makes sense
5
5
  EMPTY_PATH = [].freeze
@@ -430,7 +430,6 @@ module Foobara
430
430
  end
431
431
  end
432
432
 
433
- # TODO: can we kill this skip concept?
434
433
  def foobara_manifest
435
434
  to_include = TypeDeclarations.foobara_manifest_context_to_include
436
435
 
@@ -4,7 +4,6 @@ module Foobara
4
4
  class NoSuchOrganization < StandardError; end
5
5
 
6
6
  class << self
7
- # TODO: move this to organization.rb
8
7
  def to_organization(object)
9
8
  case object
10
9
  when nil
@@ -1,5 +1,5 @@
1
1
  module Foobara
2
- # TODO: I think we should have a configuration that indicates if created records can have primary keys past to them
2
+ # TODO: I think we should have a configuration that indicates if created records can have primary keys passed to them
3
3
  # or not. That is, do primary keys get issued by the database upon insertion? Or are they generated externally
4
4
  # and passed in? Would be nice to have programmatic clarification via explicit configuration.
5
5
  class Entity < DetachedEntity
@@ -0,0 +1,7 @@
1
+ module Foobara
2
+ module AssociationDepth
3
+ ATOM = :atom
4
+ AGGREGATE = :aggregate
5
+ PRIMARY_KEY_ONLY = :primary_key
6
+ end
7
+ end
@@ -1,43 +1,47 @@
1
1
  require "foobara/util"
2
- require "foobara/monorepo"
2
+ # TODO: Weird to have both of these requiring each other...
3
+ require "foobara"
4
+
5
+ Foobara::Util.require_directory "#{__dir__}/../../src"
3
6
 
4
7
  module Foobara
8
+ # TODO: delete this but deprecate it for now to not break other projects
9
+ Monorepo = Foobara
10
+
5
11
  module All
6
12
  # just makes Rubocop happy
7
13
  # TODO: delete this and make Rubocop exception in .rubocop.yml
8
14
  end
9
15
 
10
- module Monorepo
11
- # could be independent projects
12
- projects "delegate", # Let's just kill delegate
13
- "concerns",
14
- "weak_object_set",
15
- "enumerated",
16
- "callback",
17
- "state_machine",
18
- "namespace"
16
+ # could be independent projects
17
+ projects "delegate", # Let's just kill delegate
18
+ "concerns",
19
+ "weak_object_set",
20
+ "enumerated",
21
+ "callback",
22
+ "state_machine",
23
+ "namespace"
19
24
 
20
- # various components of the foobara framework that have some level of coupling.
21
- # for example, Error in common knows about (or could be implemented to know about)
22
- # type declarations to expose its context type.
23
- projects "domain",
24
- "common",
25
- "value",
26
- "types",
27
- "type_declarations",
28
- "builtin_types",
29
- "model",
30
- "detached_entity",
31
- "entity",
32
- "model_attribute_helpers",
33
- "nested_transactionable",
34
- "command",
35
- "domain_mapper",
36
- "persistence", # Feels like this would be loaded before command?
37
- "in_memory_crud_driver_minimal",
38
- "in_memory_crud_driver",
39
- "manifest"
25
+ # various components of the foobara framework that have some level of coupling.
26
+ # for example, Error in common knows about (or could be implemented to know about)
27
+ # type declarations to expose its context type.
28
+ projects "domain",
29
+ "common",
30
+ "value",
31
+ "types",
32
+ "type_declarations",
33
+ "builtin_types",
34
+ "model",
35
+ "detached_entity",
36
+ "entity",
37
+ "model_attribute_helpers",
38
+ "nested_transactionable",
39
+ "command",
40
+ "domain_mapper",
41
+ "persistence", # Feels like this would be loaded before command?
42
+ "in_memory_crud_driver_minimal",
43
+ "in_memory_crud_driver",
44
+ "manifest"
40
45
 
41
- install!
42
- end
46
+ install!
43
47
  end
@@ -1,3 +1,4 @@
1
+ # TODO: weird to have both these files requiring one another
1
2
  require "foobara/all"
2
3
 
3
4
  module Foobara
@@ -0,0 +1,62 @@
1
+ require_relative "project"
2
+
3
+ module Foobara
4
+ class MethodCantBeCalledInProductionError < StandardError; end
5
+
6
+ class << self
7
+ def require_project_file(project, path)
8
+ require_relative("../../#{project}/src/#{path}")
9
+ end
10
+
11
+ attr_accessor :is_installed
12
+
13
+ def all_projects
14
+ @all_projects ||= {}
15
+ end
16
+
17
+ def projects(*symbols)
18
+ symbols.each do |symbol|
19
+ project(symbol)
20
+ end
21
+ end
22
+
23
+ def project(symbol, project_path: nil)
24
+ if all_projects.key?(symbol)
25
+ # :nocov:
26
+ raise ArgumentError, "Project #{symbol} already loaded"
27
+ # :nocov:
28
+ end
29
+
30
+ project = Project.new(symbol, project_path:)
31
+ project.load
32
+
33
+ all_projects[symbol] = project
34
+
35
+ if is_installed
36
+ project.install!
37
+
38
+ all_projects.each_pair do |key, existing_project|
39
+ next if key == symbol
40
+
41
+ existing_project.new_project_added(project)
42
+ end
43
+ end
44
+ end
45
+
46
+ def install!
47
+ self.is_installed = true
48
+ all_projects.each_value(&:install!)
49
+ end
50
+
51
+ def reset_alls
52
+ raise_if_production!("reset_alls")
53
+ all_projects.each_value(&:reset_all)
54
+ end
55
+
56
+ def raise_if_production!(*)
57
+ if ENV["FOOBARA_ENV"].nil? || ENV["FOOBARA_ENV"] == "production"
58
+ raise MethodCantBeCalledInProductionError
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,48 @@
1
+ module Foobara
2
+ class Project
3
+ attr_accessor :symbol, :project_path
4
+
5
+ def initialize(symbol, project_path: nil)
6
+ self.symbol = symbol
7
+ self.project_path = project_path || "#{__dir__}/../../#{symbol}"
8
+ end
9
+
10
+ def require_path
11
+ "foobara/#{symbol}"
12
+ end
13
+
14
+ def module_name
15
+ Util.classify(symbol)
16
+ end
17
+
18
+ def module
19
+ Foobara.const_get(module_name)
20
+ end
21
+
22
+ def load
23
+ require require_path
24
+ src_dir = "#{project_path}/src"
25
+ if Dir.exist?(src_dir)
26
+ Util.require_directory(src_dir)
27
+ end
28
+ end
29
+
30
+ def install!
31
+ if self.module.respond_to?(:install!)
32
+ self.module.install!
33
+ end
34
+ end
35
+
36
+ def reset_all
37
+ if self.module.respond_to?(:reset_all)
38
+ self.module.reset_all
39
+ end
40
+ end
41
+
42
+ def new_project_added(project)
43
+ if self.module.respond_to?(:new_project_added)
44
+ self.module.new_project_added(project)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -19,8 +19,6 @@ module Foobara
19
19
  self[:manually_added]
20
20
  end
21
21
 
22
- # TODO: this has to die
23
-
24
22
  # oops, shadowed the convenience method
25
23
  def _path
26
24
  method_missing(:path)
@@ -1,9 +1,6 @@
1
1
  require "inheritable_thread_vars"
2
2
 
3
3
  module Foobara
4
- # TODO: either make this an abstract base class of ValueModel and Entity or rename it to ValueModel
5
- # and have Entity inherit from it...
6
- # TODO: also, why is this at the root level instead of in a project??
7
4
  class Model
8
5
  class NoSuchAttributeError < StandardError; end
9
6
  class AttributeIsImmutableError < StandardError; end
@@ -11,7 +11,6 @@ module Foobara
11
11
  Thread.current[:foobara_current_namespace] || global
12
12
  end
13
13
 
14
- # TODO: eliminate deprecated_namespace and yield instead
15
14
  def use(namespace)
16
15
  unless namespace.is_a?(Namespace::IsNamespace)
17
16
  # :nocov:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.134
4
+ version: 0.0.136
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -155,6 +155,7 @@ files:
155
155
  - projects/callback/src/registry/chained_conditioned.rb
156
156
  - projects/callback/src/registry/chained_multiple_action.rb
157
157
  - projects/callback/src/registry/conditioned.rb
158
+ - projects/callback/src/registry/joined_conditioned.rb
158
159
  - projects/callback/src/registry/multiple_action.rb
159
160
  - projects/callback/src/registry/single_action.rb
160
161
  - projects/callback/src/runner.rb
@@ -231,7 +232,9 @@ files:
231
232
  - projects/command_connectors/src/transformers/auth_errors_transformer.rb
232
233
  - projects/command_connectors/src/transformers/entity_to_primary_key_inputs_transformer.rb
233
234
  - projects/command_connectors/src/transformers/load_aggregates_pre_commit_transformer.rb
235
+ - projects/command_connectors/src/transformers/load_aggregates_transformer.rb
234
236
  - projects/command_connectors/src/transformers/load_atoms_pre_commit_transformer.rb
237
+ - projects/command_connectors/src/transformers/load_atoms_transformer.rb
235
238
  - projects/command_connectors/src/transformers/load_delegated_attributes_entities_pre_commit_transformer.rb
236
239
  - projects/common/lib/foobara/common.rb
237
240
  - projects/common/src/data_path.rb
@@ -288,6 +291,7 @@ files:
288
291
  - projects/domain_mapper/src/domain_mapper.rb
289
292
  - projects/domain_mapper/src/domain_mapper_lookups.rb
290
293
  - projects/entity/lib/foobara/entity.rb
294
+ - projects/entity/src/association_depth.rb
291
295
  - projects/entity/src/concerns/attributes.rb
292
296
  - projects/entity/src/concerns/callbacks.rb
293
297
  - projects/entity/src/concerns/initialization.rb
@@ -320,6 +324,8 @@ files:
320
324
  - projects/enumerated/src/values.rb
321
325
  - projects/foobara/lib/foobara.rb
322
326
  - projects/foobara/lib/foobara/all.rb
327
+ - projects/foobara/src/foobara.rb
328
+ - projects/foobara/src/project.rb
323
329
  - projects/in_memory_crud_driver/lib/foobara/in_memory_crud_driver.rb
324
330
  - projects/in_memory_crud_driver/src/in_memory.rb
325
331
  - projects/in_memory_crud_driver_minimal/lib/foobara/in_memory_crud_driver_minimal.rb
@@ -374,8 +380,6 @@ files:
374
380
  - projects/model_attribute_helpers/lib/foobara/model_attribute_helpers.rb
375
381
  - projects/model_attribute_helpers/src/attribute_helper_aliases.rb
376
382
  - projects/model_attribute_helpers/src/attribute_helpers.rb
377
- - projects/monorepo/lib/foobara/monorepo.rb
378
- - projects/monorepo/lib/foobara/monorepo/project.rb
379
383
  - projects/namespace/lib/foobara/namespace.rb
380
384
  - projects/namespace/src/ambiguous_registry.rb
381
385
  - projects/namespace/src/base_registry.rb
@@ -512,7 +516,6 @@ require_paths:
512
516
  - "./projects/manifest/lib"
513
517
  - "./projects/model/lib"
514
518
  - "./projects/model_attribute_helpers/lib"
515
- - "./projects/monorepo/lib"
516
519
  - "./projects/namespace/lib"
517
520
  - "./projects/nested_transactionable/lib"
518
521
  - "./projects/persistence/lib"
@@ -1,54 +0,0 @@
1
- module Foobara
2
- module Monorepo
3
- # TODO: make this MonorepoProject and have a more generic Project so that other projects outside of the
4
- # repo can have things like reset_all called on th.
5
- class Project
6
- attr_accessor :symbol, :project_path
7
-
8
- # TODO: we should move these concepts out of "Monorepo" and maybe into Foobara because we sometimes need to
9
- # be able to install!/reset foobara code that's been extracted into a gem
10
- def initialize(symbol, project_path: nil)
11
- self.symbol = symbol
12
- self.project_path = project_path || "#{__dir__}/../../../../../projects/#{symbol}"
13
- end
14
-
15
- def require_path
16
- "foobara/#{symbol}"
17
- end
18
-
19
- def module_name
20
- Util.classify(symbol)
21
- end
22
-
23
- def module
24
- Foobara.const_get(module_name)
25
- end
26
-
27
- def load
28
- require require_path
29
- src_dir = "#{project_path}/src"
30
- if Dir.exist?(src_dir)
31
- Util.require_directory(src_dir)
32
- end
33
- end
34
-
35
- def install!
36
- if self.module.respond_to?(:install!)
37
- self.module.install!
38
- end
39
- end
40
-
41
- def reset_all
42
- if self.module.respond_to?(:reset_all)
43
- self.module.reset_all
44
- end
45
- end
46
-
47
- def new_project_added(project)
48
- if self.module.respond_to?(:new_project_added)
49
- self.module.new_project_added(project)
50
- end
51
- end
52
- end
53
- end
54
- end
@@ -1,63 +0,0 @@
1
- require_relative "monorepo/project"
2
-
3
- module Foobara
4
- class << self
5
- def require_project_file(project, path)
6
- require_relative("../../../#{project}/src/#{path}")
7
- end
8
-
9
- def reset_alls
10
- Monorepo.reset_alls
11
- end
12
- end
13
-
14
- # TODO: We should rename this to Projects or something else because we need to manage this stuff for projects
15
- # inside and outside of the monorepo.
16
- module Monorepo
17
- class << self
18
- attr_accessor :is_installed
19
-
20
- def all_projects
21
- @all_projects ||= {}
22
- end
23
-
24
- def projects(*symbols)
25
- symbols.each do |symbol|
26
- project(symbol)
27
- end
28
- end
29
-
30
- def project(symbol, project_path: nil)
31
- if all_projects.key?(symbol)
32
- # :nocov:
33
- raise ArgumentError, "Project #{symbol} already loaded"
34
- # :nocov:
35
- end
36
-
37
- project = Project.new(symbol, project_path:)
38
- project.load
39
-
40
- all_projects[symbol] = project
41
-
42
- if is_installed
43
- project.install!
44
-
45
- all_projects.each_pair do |key, existing_project|
46
- next if key == symbol
47
-
48
- existing_project.new_project_added(project)
49
- end
50
- end
51
- end
52
-
53
- def install!
54
- self.is_installed = true
55
- all_projects.each_value(&:install!)
56
- end
57
-
58
- def reset_alls
59
- all_projects.each_value(&:reset_all)
60
- end
61
- end
62
- end
63
- end