foobara 0.0.116 → 0.0.117

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/projects/builtin_types/src/date/casters/hash.rb +1 -1
  4. data/projects/callback/src/block.rb +1 -1
  5. data/projects/command/src/command_pattern_implementation/concerns/callbacks.rb +2 -2
  6. data/projects/command/src/command_pattern_implementation/concerns/runtime.rb +7 -7
  7. data/projects/command/src/state_machine.rb +22 -22
  8. data/projects/command_connectors/src/authenticator.rb +3 -1
  9. data/projects/command_connectors/src/command_connector/command_connector_error.rb +1 -1
  10. data/projects/command_connectors/src/command_connector/request.rb +1 -1
  11. data/projects/command_connectors/src/command_registry.rb +1 -1
  12. data/projects/detached_entity/src/concerns/attributes.rb +28 -0
  13. data/projects/detached_entity/src/concerns/initialization.rb +57 -0
  14. data/projects/detached_entity/src/concerns/persistence.rb +14 -0
  15. data/projects/detached_entity/src/detached_entity.rb +3 -0
  16. data/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +43 -0
  17. data/projects/entity/src/concerns/attributes.rb +4 -0
  18. data/projects/entity/src/concerns/callbacks.rb +16 -16
  19. data/projects/entity/src/concerns/initialization.rb +3 -0
  20. data/projects/entity/src/concerns/persistence.rb +1 -5
  21. data/projects/entity/src/extensions/builtin_types/entity/casters/primary_key.rb +3 -29
  22. data/projects/enumerated/src/values.rb +1 -1
  23. data/projects/manifest/src/foobara/manifest/base_manifest.rb +2 -2
  24. data/projects/manifest/src/foobara/manifest/root_manifest.rb +1 -1
  25. data/projects/model/src/concerns/types.rb +1 -1
  26. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +2 -2
  27. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +1 -1
  28. data/projects/model/src/model.rb +4 -3
  29. data/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +11 -11
  30. data/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +5 -5
  31. data/projects/type_declarations/lib/foobara/type_declarations.rb +4 -4
  32. data/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +1 -1
  33. data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +1 -1
  34. data/projects/type_declarations/src/type_declarations.rb +2 -2
  35. data/projects/value/src/caster.rb +2 -2
  36. data/projects/value/src/processor.rb +2 -2
  37. data/projects/value/src/transformer.rb +2 -2
  38. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe51e6ab90aafb99246fd2872f0faa452004f71b0d37a7e68a2fc7e8027feff7
4
- data.tar.gz: d9027059c2a75b268950b661e5c3bb3fd1d633f52afbbe6d302c8ba3351908bc
3
+ metadata.gz: 3baedff1b00683e94d063e4a3c3453e89f9d8383aac79fd63a7b80590b7ac2ab
4
+ data.tar.gz: db340140596337684becb59db82ef8c9f64970195eace6d2cb0032d6e209eb88
5
5
  SHA512:
6
- metadata.gz: 3beecfb43803f74a01d9f1d6e36c6b6f10c5abbae6dc3eaf9bc9a62afe25d3413313ed6f65262ba4e4c165e8545bbb506f045cafbd3d7673a37d4b87e9202661
7
- data.tar.gz: 34554e412fc605f453392d2432f59311abe65498ec0db28e1c617c61b4c7fb1ac4e1bd7140f1ee8064482355a6a90e800cefea7b2ea8f35e23ad00eed59cf674
6
+ metadata.gz: a9cfde792ff8303519b9b98ca46062a7e0dc4209799e00bd64bf3d5674112e685eb8cce621eb50cda6680c54f76084076007d3c18125baefe14eb052566f9038
7
+ data.tar.gz: db3398f6804081f01a44ac188a0597831db3b3ffa0dfa81ffb99de75c01685e33d21d4d91dbefae6e7d601bae29676e60c778e7be59cb3120bfde7dd7ba1b19a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [0.0.117] - 2025-05-05
2
+
3
+ - Make sure we do not apply an authenticator unless it is applicable
4
+ - Move loaded/unloaded concept up into DetachedEntity from Entity
5
+ - This allows us to deal with serialization of detached entities as their primary keys
6
+ - Fix bugs preventing connecting/importing types with delegated attributes
7
+
1
8
  # [0.0.116] - 2025-05-03
2
9
 
3
10
  - Add automatic transaction support to requests, cover in/out mutators/transformers
@@ -4,7 +4,7 @@ module Foobara
4
4
  module Casters
5
5
  class Hash < Value::Caster
6
6
  def applicable?(hash)
7
- hash.is_a?(::Hash) && hash.keys.size == 3 && (hash.keys.map(&:to_s).sort == %w[day month year])
7
+ hash.is_a?(::Hash) && hash.keys.size == 3 && (hash.keys.map(&:to_s).sort == ["day", "month", "year"])
8
8
  end
9
9
 
10
10
  def applies_message
@@ -56,7 +56,7 @@ module Foobara
56
56
  end
57
57
 
58
58
  def has_keyword_args?
59
- @has_keyword_args ||= param_types.any? { |type| %i[keyreq keyrest].include?(type) }
59
+ @has_keyword_args ||= param_types.any? { |type| [:keyreq, :keyrest].include?(type) }
60
60
  end
61
61
 
62
62
  def has_positional_args?
@@ -28,7 +28,7 @@ module Foobara
28
28
  self.subclass_defined_callbacks ||= Foobara::Callback::Registry::SingleAction.new
29
29
 
30
30
  [self, singleton_class].each do |target|
31
- %i[before after].each do |type|
31
+ [:before, :after].each do |type|
32
32
  target.define_method "#{type}_any_transition" do |&block|
33
33
  callback_state_machine_target.register_transition_callback(type) do |state_machine:, **args|
34
34
  block.call(command: state_machine.owner, **args)
@@ -61,7 +61,7 @@ module Foobara
61
61
 
62
62
  Foobara::Command::StateMachine.transitions.each do |transition|
63
63
  [self, singleton_class].each do |target|
64
- %i[before after].each do |type|
64
+ [:before, :after].each do |type|
65
65
  target.define_method "#{type}_#{transition}" do |&block|
66
66
  callback_state_machine_target.register_transition_callback(
67
67
  type, transition:
@@ -27,13 +27,13 @@ module Foobara
27
27
  Foobara::Namespace.use self.class do
28
28
  invoke_with_callbacks_and_transition(:open_transaction)
29
29
 
30
- invoke_with_callbacks_and_transition_in_transaction(%i[
31
- cast_and_validate_inputs
32
- load_records
33
- validate_records
34
- validate
35
- run_execute
36
- commit_transaction
30
+ invoke_with_callbacks_and_transition_in_transaction([
31
+ :cast_and_validate_inputs,
32
+ :load_records,
33
+ :validate_records,
34
+ :validate,
35
+ :run_execute,
36
+ :commit_transaction
37
37
  ])
38
38
 
39
39
  invoke_with_callbacks_and_transition(:succeed)
@@ -1,31 +1,31 @@
1
1
  module Foobara
2
2
  class Command
3
3
  class StateMachine < Foobara::StateMachine
4
- transitions = %i[
5
- open_transaction
6
- cast_and_validate_inputs
7
- load_records
8
- validate_records
9
- validate
10
- run_execute
11
- commit_transaction
12
- succeed
13
- error
14
- fail
15
- reset
4
+ transitions = [
5
+ :open_transaction,
6
+ :cast_and_validate_inputs,
7
+ :load_records,
8
+ :validate_records,
9
+ :validate,
10
+ :run_execute,
11
+ :commit_transaction,
12
+ :succeed,
13
+ :error,
14
+ :fail,
15
+ :reset
16
16
  ]
17
17
 
18
- terminal_states = %i[succeeded errored failed]
18
+ terminal_states = [:succeeded, :errored, :failed]
19
19
 
20
- states = %i[
21
- initialized
22
- transaction_opened
23
- inputs_casted_and_validated
24
- loaded_records
25
- validated_records
26
- validated_execution
27
- executing
28
- transaction_committed
20
+ states = [
21
+ :initialized,
22
+ :transaction_opened,
23
+ :inputs_casted_and_validated,
24
+ :loaded_records,
25
+ :validated_records,
26
+ :validated_execution,
27
+ :executing,
28
+ :transaction_committed
29
29
  ] + terminal_states
30
30
 
31
31
  can_fail_states = states - terminal_states
@@ -30,7 +30,9 @@ module Foobara
30
30
  end
31
31
 
32
32
  def authenticate(request)
33
- process_value!(request)
33
+ if applicable?(request)
34
+ process_value!(request)
35
+ end
34
36
  end
35
37
 
36
38
  def to_proc
@@ -3,7 +3,7 @@ module Foobara
3
3
  class CommandConnectorError < Foobara::RuntimeError
4
4
  context({})
5
5
 
6
- def initialize(message:, context: {})
6
+ def initialize(message:, symbol: nil, context: {})
7
7
  super
8
8
  end
9
9
  end
@@ -19,7 +19,7 @@ module Foobara
19
19
  :authenticated_credential
20
20
 
21
21
  def initialize(**opts)
22
- valid_keys = %i[inputs full_command_name action serializers]
22
+ valid_keys = [:inputs, :full_command_name, :action, :serializers]
23
23
 
24
24
  invalid_keys = opts.keys - valid_keys
25
25
 
@@ -13,7 +13,7 @@ module Foobara
13
13
  self.scoped_path = []
14
14
  self.authenticator = authenticator
15
15
 
16
- customized = %i[command]
16
+ customized = [:command]
17
17
 
18
18
  Namespace.global.foobara_categories.keys.reverse.each do |symbol|
19
19
  next if customized.include?(symbol)
@@ -0,0 +1,28 @@
1
+ module Foobara
2
+ class DetachedEntity < Model
3
+ class CannotReadAttributeOnUnloadedRecordError < StandardError; end
4
+
5
+ module Concerns
6
+ module Attributes
7
+ include Concern
8
+
9
+ def read_attribute(attribute_name)
10
+ attribute_name = attribute_name.to_sym
11
+
12
+ if attribute_name != self.class.primary_key_attribute
13
+ unless can_read_attributes_other_than_primary_key?
14
+ raise CannotReadAttributeOnUnloadedRecordError,
15
+ "Cannot read attribute #{attribute_name} on unloaded record"
16
+ end
17
+ end
18
+
19
+ super
20
+ end
21
+
22
+ def can_read_attributes_other_than_primary_key?
23
+ loaded?
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,57 @@
1
+ module Foobara
2
+ class DetachedEntity < Model
3
+ class NoCurrentTransactionError < StandardError; end
4
+
5
+ module Concerns
6
+ module Initialization
7
+ include Concern
8
+
9
+ module ClassMethods
10
+ def unloaded(primary_key_value)
11
+ primary_key_value = primary_key_type.process_value!(primary_key_value)
12
+
13
+ new({ primary_key_attribute => primary_key_value }, unloaded: true)
14
+ end
15
+ end
16
+
17
+ ALLOWED_OPTIONS = Model::ALLOWED_OPTIONS + [:unloaded]
18
+
19
+ def initialize(attributes = nil, options = {})
20
+ invalid_options = options.keys - ALLOWED_OPTIONS
21
+
22
+ unless invalid_options.empty?
23
+ # :nocov:
24
+ raise ArgumentError, "Invalid options #{invalid_options} expected only #{ALLOWED_OPTIONS}"
25
+ # :nocov:
26
+ end
27
+
28
+ if options[:unloaded]
29
+ options = options.except(:unloaded)
30
+
31
+ unless options.key?(:validate)
32
+ options[:validate] = false
33
+ end
34
+
35
+ unless options.key?(:skip_validations)
36
+ options[:skip_validations] = true
37
+ end
38
+
39
+ unless options.key?(:ignore_unexpected_attributes)
40
+ options[:ignore_unexpected_attributes] = false
41
+ end
42
+
43
+ unless options.key?(:mutable)
44
+ options[:mutable] = false
45
+ end
46
+
47
+ super
48
+ self.is_loaded = false
49
+ else
50
+ super
51
+ self.is_loaded = true
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,14 @@
1
+ module Foobara
2
+ class DetachedEntity < Model
3
+ module Concerns
4
+ # Too simple to include Concern
5
+ module Persistence
6
+ attr_accessor :is_loaded
7
+
8
+ def loaded?
9
+ is_loaded
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,7 @@
1
1
  module Foobara
2
2
  class DetachedEntity < Model
3
+ include Concerns::Attributes
4
+ include Concerns::Persistence
3
5
  include Concerns::Equality
4
6
  include Concerns::Associations
5
7
  include Concerns::PrimaryKey
@@ -7,5 +9,6 @@ module Foobara
7
9
  include Concerns::Types
8
10
  include Concerns::Aliases
9
11
  include Concerns::Serialize
12
+ include Concerns::Initialization
10
13
  end
11
14
  end
@@ -0,0 +1,43 @@
1
+ module Foobara
2
+ module BuiltinTypes
3
+ module DetachedEntity
4
+ module Casters
5
+ class PrimaryKey < Value::Caster
6
+ class << self
7
+ def requires_declaration_data?
8
+ true
9
+ end
10
+
11
+ def requires_type?
12
+ true
13
+ end
14
+ end
15
+
16
+ def entity_class
17
+ declaration_data.target_class
18
+ end
19
+
20
+ def primary_key_type
21
+ entity_class.primary_key_type
22
+ end
23
+
24
+ def applicable?(value)
25
+ primary_key_type.applicable?(value)
26
+ end
27
+
28
+ def transform(primary_key)
29
+ entity_class.send(build_method, primary_key)
30
+ end
31
+
32
+ def applies_message
33
+ primary_key_type.value_caster.applies_message
34
+ end
35
+
36
+ def build_method
37
+ :unloaded
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -6,6 +6,10 @@ module Foobara
6
6
 
7
7
  include Concern
8
8
 
9
+ def can_read_attributes_other_than_primary_key?
10
+ loaded? || built? || created?
11
+ end
12
+
9
13
  def write_attribute_without_callbacks(attribute_name, value)
10
14
  without_callbacks do
11
15
  write_attribute(attribute_name, value)
@@ -39,22 +39,22 @@ module Foobara
39
39
  module ClassMethods
40
40
  def class_callback_registry
41
41
  @class_callback_registry ||= begin
42
- actions = %i[
43
- initialized
44
- initialized_built
45
- initialized_thunk
46
- initialized_loaded
47
- initialized_created
48
- dirtied
49
- undirtied
50
- attribute_changed
51
- reverted
52
- loaded
53
- persisted
54
- hard_deleted
55
- unhard_deleted
56
- invalidated
57
- uninvalidated
42
+ actions = [
43
+ :initialized,
44
+ :initialized_built,
45
+ :initialized_thunk,
46
+ :initialized_loaded,
47
+ :initialized_created,
48
+ :dirtied,
49
+ :undirtied,
50
+ :attribute_changed,
51
+ :reverted,
52
+ :loaded,
53
+ :persisted,
54
+ :hard_deleted,
55
+ :unhard_deleted,
56
+ :invalidated,
57
+ :uninvalidated
58
58
  ]
59
59
 
60
60
  if self == Entity
@@ -16,6 +16,7 @@ module Foobara
16
16
  record.build(attributes)
17
17
  # TODO: rename to something like "detached"
18
18
  record.is_built = true
19
+ record.is_loaded = false
19
20
 
20
21
  record.fire(:initialized)
21
22
  record.fire(:initialized_built)
@@ -39,6 +40,7 @@ module Foobara
39
40
  return record if record
40
41
 
41
42
  record = __private_new__
43
+ record.is_loaded = false
42
44
  record.is_persisted = true
43
45
  record.write_attributes_without_callbacks(primary_key_attribute => record_id)
44
46
 
@@ -80,6 +82,7 @@ module Foobara
80
82
  def create(attributes = {})
81
83
  record = __private_new__
82
84
  record.is_created = true
85
+ record.is_loaded = false
83
86
 
84
87
  defaults = attributes_type.declaration_data[:defaults]
85
88
  if defaults && !defaults.empty?
@@ -7,7 +7,7 @@ module Foobara
7
7
 
8
8
  include Concern
9
9
 
10
- attr_accessor :is_loaded, :is_persisted, :is_hard_deleted, :is_built, :is_created, :persisted_attributes
10
+ attr_accessor :is_persisted, :is_hard_deleted, :is_built, :is_created, :persisted_attributes
11
11
 
12
12
  module ClassMethods
13
13
  def entity_base
@@ -50,10 +50,6 @@ module Foobara
50
50
  is_created
51
51
  end
52
52
 
53
- def loaded?
54
- is_loaded
55
- end
56
-
57
53
  # TODO: rename, maybe #detatched? or something?
58
54
  def built?
59
55
  is_built
@@ -2,35 +2,9 @@ module Foobara
2
2
  module BuiltinTypes
3
3
  module Entity
4
4
  module Casters
5
- class PrimaryKey < Value::Caster
6
- class << self
7
- def requires_declaration_data?
8
- true
9
- end
10
-
11
- def requires_type?
12
- true
13
- end
14
- end
15
-
16
- def entity_class
17
- declaration_data.target_class
18
- end
19
-
20
- def primary_key_type
21
- entity_class.primary_key_type
22
- end
23
-
24
- def applicable?(value)
25
- primary_key_type.applicable?(value)
26
- end
27
-
28
- def transform(primary_key)
29
- entity_class.thunk(primary_key)
30
- end
31
-
32
- def applies_message
33
- primary_key_type.value_caster.applies_message
5
+ class PrimaryKey < DetachedEntity::Casters::PrimaryKey
6
+ def build_method
7
+ :thunk
34
8
  end
35
9
  end
36
10
  end
@@ -125,7 +125,7 @@ module Foobara
125
125
  mod = Module.new
126
126
  enumerated = self
127
127
 
128
- %i[all all_names all_values value?].each do |method_name|
128
+ [:all, :all_names, :all_values, :value?].each do |method_name|
129
129
  mod.singleton_class.define_method method_name do |*args, **opts, &block|
130
130
  enumerated.send(method_name, *args, **opts, &block)
131
131
  end
@@ -103,11 +103,11 @@ module Foobara
103
103
  end
104
104
 
105
105
  def global_domain
106
- Domain.new(root_manifest, %i[domain global_organization::global_domain])
106
+ Domain.new(root_manifest, [:domain, :"global_organization::global_domain"])
107
107
  end
108
108
 
109
109
  def global_organization
110
- Organization.new(root_manifest, %i[organization global_organization])
110
+ Organization.new(root_manifest, [:organization, :global_organization])
111
111
  end
112
112
 
113
113
  def method_missing(method_name, *, &)
@@ -102,7 +102,7 @@ module Foobara
102
102
  end
103
103
 
104
104
  def lookup(reference)
105
- prioritized_categories = %i[command type error domain organization processor processor_class]
105
+ prioritized_categories = [:command, :type, :error, :domain, :organization, :processor, :processor_class]
106
106
 
107
107
  prioritized_categories.each do |category|
108
108
  path = [category, reference]
@@ -199,7 +199,7 @@ module Foobara
199
199
  delegates[attribute_name] = delegate_manifest
200
200
 
201
201
  delegated_type_declaration = model_type.type_at_path(data_path).reference_or_declaration_data
202
- attributes attribute_name => delegated_type_declaration
202
+ attributes(type: :attributes, element_type_declarations: { attribute_name => delegated_type_declaration })
203
203
 
204
204
  define_method attribute_name do
205
205
  data_path.value_at(self)
@@ -8,8 +8,8 @@ module Foobara
8
8
  end
9
9
 
10
10
  def desugarize(sugary_type_declaration)
11
- desugarized = Util.deep_dup(sugary_type_declaration)
12
- delegates = desugarized[:delegates]
11
+ desugarized = sugary_type_declaration.dup
12
+ delegates = Util.deep_symbolize_keys(desugarized[:delegates])
13
13
 
14
14
  if delegates.empty?
15
15
  desugarized.delete(:delegates)
@@ -21,7 +21,7 @@ module Foobara
21
21
  )
22
22
  end
23
23
 
24
- allowed_keys = %i[data_path writer]
24
+ allowed_keys = [:data_path, :writer]
25
25
 
26
26
  delegates.each_pair do |attribute_name, delegate_hash|
27
27
  invalid_keys = delegate_hash.keys - allowed_keys
@@ -171,13 +171,14 @@ module Foobara
171
171
 
172
172
  attr_accessor :mutable, :skip_validations
173
173
 
174
+ ALLOWED_OPTIONS = [:validate, :mutable, :ignore_unexpected_attributes, :skip_validations].freeze
175
+
174
176
  def initialize(attributes = nil, options = {})
175
- allowed_options = %i[validate mutable ignore_unexpected_attributes skip_validations]
176
- invalid_options = options.keys - allowed_options
177
+ invalid_options = options.keys - ALLOWED_OPTIONS
177
178
 
178
179
  unless invalid_options.empty?
179
180
  # :nocov:
180
- raise ArgumentError, "Invalid options #{invalid_options} expected only #{allowed_options}"
181
+ raise ArgumentError, "Invalid options #{invalid_options} expected only #{ALLOWED_OPTIONS}"
181
182
  # :nocov:
182
183
  end
183
184
 
@@ -7,17 +7,17 @@ module Foobara
7
7
  include Foobara::Concern
8
8
 
9
9
  module ClassMethods
10
- %i[
11
- attributes_for_update
12
- type_from_foobara_model_class
13
- attributes_type_from_foobara_model_class
14
- primary_key_attribute_from_foobara_model_class
15
- foobara_model_class_has_primary_key
16
- attributes_for_create
17
- attributes_for_aggregate_update
18
- attributes_for_atom_update
19
- attributes_for_find_by
20
- type_declaration_value_at
10
+ [
11
+ :attributes_for_update,
12
+ :type_from_foobara_model_class,
13
+ :attributes_type_from_foobara_model_class,
14
+ :primary_key_attribute_from_foobara_model_class,
15
+ :foobara_model_class_has_primary_key,
16
+ :attributes_for_create,
17
+ :attributes_for_aggregate_update,
18
+ :attributes_for_atom_update,
19
+ :attributes_for_find_by,
20
+ :type_declaration_value_at
21
21
  ].each do |method_name|
22
22
  define_method method_name do |*args, **opts, &block|
23
23
  send("foobara_#{method_name}", *args, **opts, &block)
@@ -95,11 +95,11 @@ module Foobara
95
95
  marked_created.clear
96
96
  end
97
97
 
98
- interesting_record_states = %i[
99
- updated
100
- hard_deleted
101
- created
102
- loading
98
+ interesting_record_states = [
99
+ :updated,
100
+ :hard_deleted,
101
+ :created,
102
+ :loading
103
103
  ]
104
104
 
105
105
  interesting_record_states.each do |state|
@@ -17,10 +17,10 @@ module Foobara
17
17
  end
18
18
  end
19
19
 
20
- %w[
21
- foobara_children
22
- foobara_registry
23
- foobara_type_builder
20
+ [
21
+ "foobara_children",
22
+ "foobara_registry",
23
+ "foobara_type_builder"
24
24
  ].each do |var_name|
25
25
  var_name = "@#{var_name}"
26
26
 
@@ -8,7 +8,7 @@ module Foobara
8
8
  class TypeSetToArrayDesugarizer < ArrayDesugarizer
9
9
  def applicable?(sugary_type_declaration)
10
10
  if sugary_type_declaration.is_a?(::Hash) && sugary_type_declaration.key?(:type)
11
- extra_keys = sugary_type_declaration.keys - %i[type description sensitive sensitive_exposed]
11
+ extra_keys = sugary_type_declaration.keys - [:type, :description, :sensitive, :sensitive_exposed]
12
12
 
13
13
  return false if extra_keys.any?
14
14
 
@@ -74,7 +74,7 @@ module Foobara
74
74
  end
75
75
 
76
76
  def non_processor_keys
77
- %i[type _desugarized description sensitive sensitive_exposed]
77
+ [:type, :_desugarized, :description, :sensitive, :sensitive_exposed]
78
78
  end
79
79
  end
80
80
  end
@@ -96,8 +96,8 @@ module Foobara
96
96
  Thread.inheritable_thread_local_var_get("foobara_manifest_context")
97
97
  end
98
98
 
99
- allowed_context_keys = %i[detached to_include mode remove_sensitive]
100
- booleans = %i[detached remove_sensitive]
99
+ allowed_context_keys = [:detached, :to_include, :mode, :remove_sensitive]
100
+ booleans = [:detached, :remove_sensitive]
101
101
 
102
102
  booleans.each do |context_item|
103
103
  define_method "foobara_manifest_context_#{context_item}?" do
@@ -16,8 +16,8 @@ module Foobara
16
16
  end
17
17
 
18
18
  def subclass(name: nil, **options)
19
- arity_zero = %i[name applies_message]
20
- arity_one = %i[applicable? cast]
19
+ arity_zero = [:name, :applies_message]
20
+ arity_one = [:applicable?, :cast]
21
21
  allowed = arity_zero + arity_one
22
22
 
23
23
  invalid_options = options.keys - allowed
@@ -48,7 +48,7 @@ module Foobara
48
48
  end
49
49
 
50
50
  def new_with_agnostic_args(**rest)
51
- allowed_keys = %i[declaration_data parent_declaration_data]
51
+ allowed_keys = [:declaration_data, :parent_declaration_data]
52
52
 
53
53
  invalid_keys = rest.keys - allowed_keys
54
54
 
@@ -283,7 +283,7 @@ module Foobara
283
283
  end
284
284
 
285
285
  def dup_processor(**opts)
286
- valid_opts = %i[declaration_data parent_declaration_data]
286
+ valid_opts = [:declaration_data, :parent_declaration_data]
287
287
 
288
288
  invalid_opts = opts.keys - valid_opts
289
289
 
@@ -24,8 +24,8 @@ module Foobara
24
24
 
25
25
  # TODO: make transform the first argument for convenience
26
26
  def subclass(name: nil, **options)
27
- arity_zero = %i[always_applicable? priority]
28
- arity_one = %i[applicable? transform]
27
+ arity_zero = [:always_applicable?, :priority]
28
+ arity_one = [:applicable?, :transform]
29
29
  allowed = arity_zero + arity_one
30
30
 
31
31
  invalid_options = options.keys - allowed
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.116
4
+ version: 0.0.117
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-03 00:00:00.000000000 Z
10
+ date: 2025-05-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bigdecimal
@@ -234,7 +234,10 @@ files:
234
234
  - projects/detached_entity/lib/foobara/detached_entity.rb
235
235
  - projects/detached_entity/src/concerns/aliases.rb
236
236
  - projects/detached_entity/src/concerns/associations.rb
237
+ - projects/detached_entity/src/concerns/attributes.rb
237
238
  - projects/detached_entity/src/concerns/equality.rb
239
+ - projects/detached_entity/src/concerns/initialization.rb
240
+ - projects/detached_entity/src/concerns/persistence.rb
238
241
  - projects/detached_entity/src/concerns/primary_key.rb
239
242
  - projects/detached_entity/src/concerns/reflection.rb
240
243
  - projects/detached_entity/src/concerns/serialize.rb
@@ -243,6 +246,7 @@ files:
243
246
  - projects/detached_entity/src/detached_entity_type.rb
244
247
  - projects/detached_entity/src/extensions/builtin_types/detached_entity.rb
245
248
  - projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/hash.rb
249
+ - projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb
246
250
  - projects/detached_entity/src/extensions/builtin_types/detached_entity/validators/model_instance_is_valid.rb
247
251
  - projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration.rb
248
252
  - projects/detached_entity/src/extensions/type_declarations/handlers/extend_detached_entity_type_declaration/attributes_handler_desugarizer.rb