foobara 0.0.115 → 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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -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/command_pattern_implementation/concerns/transactions.rb +10 -69
  8. data/projects/command/src/state_machine.rb +22 -22
  9. data/projects/command_connectors/src/authenticator.rb +7 -1
  10. data/projects/command_connectors/src/authenticator_selector.rb +8 -0
  11. data/projects/command_connectors/src/command_connector/command_connector_error.rb +1 -1
  12. data/projects/command_connectors/src/command_connector/request.rb +56 -11
  13. data/projects/command_connectors/src/command_connector/response.rb +4 -0
  14. data/projects/command_connectors/src/command_connector.rb +92 -97
  15. data/projects/command_connectors/src/command_registry.rb +1 -1
  16. data/projects/command_connectors/src/serializers/entities_to_primary_keys_serializer.rb +8 -1
  17. data/projects/{command → command_connectors}/src/transformed_command.rb +16 -7
  18. data/projects/detached_entity/src/concerns/attributes.rb +28 -0
  19. data/projects/detached_entity/src/concerns/initialization.rb +57 -0
  20. data/projects/detached_entity/src/concerns/persistence.rb +14 -0
  21. data/projects/detached_entity/src/detached_entity.rb +3 -0
  22. data/projects/detached_entity/src/extensions/builtin_types/detached_entity/casters/primary_key.rb +43 -0
  23. data/projects/entity/src/concerns/attributes.rb +4 -0
  24. data/projects/entity/src/concerns/callbacks.rb +16 -16
  25. data/projects/entity/src/concerns/initialization.rb +3 -0
  26. data/projects/entity/src/concerns/persistence.rb +1 -5
  27. data/projects/entity/src/extensions/builtin_types/entity/casters/primary_key.rb +3 -29
  28. data/projects/entity/src/sensitive_type_removers/entity.rb +15 -0
  29. data/projects/entity/src/sensitive_value_removers/entity.rb +14 -14
  30. data/projects/enumerated/src/values.rb +1 -1
  31. data/projects/foobara/lib/foobara/all.rb +2 -1
  32. data/projects/manifest/src/foobara/manifest/base_manifest.rb +2 -2
  33. data/projects/manifest/src/foobara/manifest/root_manifest.rb +1 -1
  34. data/projects/model/src/concerns/types.rb +3 -2
  35. data/projects/model/src/extensions/builtin_types/model/validators/model_instance_is_valid.rb +2 -2
  36. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_desugarizer.rb +2 -2
  37. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/delegates_validator.rb +1 -1
  38. data/projects/model/src/extensions/type_declarations/handlers/extend_model_type_declaration/model_class_desugarizer.rb +3 -1
  39. data/projects/model/src/model.rb +8 -5
  40. data/projects/model_attribute_helpers/src/attribute_helper_aliases.rb +11 -11
  41. data/projects/monorepo/lib/foobara/monorepo/project.rb +4 -1
  42. data/projects/nested_transactionable/lib/foobara/nested_transactionable.rb +95 -0
  43. data/projects/persistence/src/entity_base/transaction_table/concerns/record_tracking.rb +5 -5
  44. data/projects/type_declarations/lib/foobara/type_declarations.rb +4 -4
  45. data/projects/type_declarations/src/handlers/extend_array_type_declaration/type_set_to_array_desugarizer.rb +1 -1
  46. data/projects/type_declarations/src/handlers/extend_registered_type_declaration/to_type_transformer.rb +1 -1
  47. data/projects/type_declarations/src/type_declarations.rb +2 -2
  48. data/projects/value/src/caster.rb +2 -2
  49. data/projects/value/src/processor.rb +2 -2
  50. data/projects/value/src/transformer.rb +2 -2
  51. metadata +9 -3
@@ -154,15 +154,11 @@ module Foobara
154
154
  command_registry.foobara_lookup_command(name)
155
155
  end
156
156
 
157
- # TODO: maybe instead connect commands with a shortcut_only: "describe" option
158
- # in order to make this easier to extend and manage.
159
- def request_to_command(request)
157
+ def request_to_command_class(request)
160
158
  action = request.action
161
- inputs = nil
162
159
  full_command_name = request.full_command_name
163
160
 
164
- case action
165
- when "run"
161
+ if action == "run"
166
162
  transformed_command_class = transformed_command_from_name(full_command_name)
167
163
 
168
164
  unless transformed_command_class
@@ -171,9 +167,36 @@ module Foobara
171
167
  # :nocov:
172
168
  end
173
169
 
174
- request.command_class = transformed_command_class
170
+ transformed_command_class
171
+ else
172
+ action = case action
173
+ when "describe_type", "manifest", "describe_command"
174
+ "describe"
175
+ when "describe", "ping", "query_git_commit_info", "help"
176
+ action
177
+ when "list"
178
+ "list_commands"
179
+ else
180
+ # :nocov:
181
+ raise InvalidContextError.new(message: "Not sure what to do with #{action}")
182
+ # :nocov:
183
+ end
184
+
185
+ command_name = Util.classify(action)
186
+ command_class = find_builtin_command_class(command_name)
187
+ full_command_name = command_class.full_command_name
188
+
189
+ transformed_command_from_name(full_command_name) || transform_command_class(command_class)
190
+ end
191
+ end
192
+
193
+ def request_to_command_inputs(request)
194
+ action = request.action
195
+ full_command_name = request.full_command_name
175
196
 
176
- inputs = request.inputs
197
+ case action
198
+ when "run"
199
+ request.inputs
177
200
  when "describe"
178
201
  manifestable = transformed_command_from_name(full_command_name) || type_from_name(full_command_name)
179
202
 
@@ -185,13 +208,7 @@ module Foobara
185
208
  # :nocov:
186
209
  end
187
210
 
188
- command_class = find_builtin_command_class("Describe")
189
- full_command_name = command_class.full_command_name
190
-
191
- inputs = request.inputs.merge(manifestable:, request:)
192
-
193
- transformed_command_class = transformed_command_from_name(full_command_name) ||
194
- transform_command_class(command_class)
211
+ request.inputs.merge(manifestable:, request:)
195
212
  when "describe_command"
196
213
  transformed_command_class = transformed_command_from_name(full_command_name)
197
214
 
@@ -201,12 +218,7 @@ module Foobara
201
218
  # :nocov:
202
219
  end
203
220
 
204
- command_class = find_builtin_command_class("Describe")
205
- full_command_name = command_class.full_command_name
206
-
207
- inputs = request.inputs.merge(manifestable: transformed_command_class, request:)
208
- transformed_command_class = transformed_command_from_name(full_command_name) ||
209
- transform_command_class(command_class)
221
+ request.inputs.merge(manifestable: transformed_command_class, request:)
210
222
  when "describe_type"
211
223
  type = type_from_name(full_command_name)
212
224
 
@@ -216,59 +228,30 @@ module Foobara
216
228
  # :nocov:
217
229
  end
218
230
 
219
- command_class = find_builtin_command_class("Describe")
220
- full_command_name = command_class.full_command_name
221
-
222
- inputs = request.inputs.merge(manifestable: type, request:)
223
- transformed_command_class = transformed_command_from_name(full_command_name) ||
224
- transform_command_class(command_class)
231
+ request.inputs.merge(manifestable: type, request:)
225
232
  when "manifest"
226
- command_class = find_builtin_command_class("Describe")
227
- full_command_name = command_class.full_command_name
228
-
229
- inputs = request.inputs.merge(manifestable: self, request:)
230
- transformed_command_class = transformed_command_from_name(full_command_name) ||
231
- transform_command_class(command_class)
232
- when "ping"
233
- command_class = find_builtin_command_class("Ping")
234
- full_command_name = command_class.full_command_name
235
-
236
- transformed_command_class = transformed_command_from_name(full_command_name) ||
237
- transform_command_class(command_class)
238
- when "query_git_commit_info"
239
- # TODO: this feels out of control... should just accomplish this through run I think instead. Same with ping.
240
- command_class = find_builtin_command_class("QueryGitCommitInfo")
241
- full_command_name = command_class.full_command_name
242
-
243
- transformed_command_class = transformed_command_from_name(full_command_name) ||
244
- transform_command_class(command_class)
233
+ request.inputs.merge(manifestable: self, request:)
234
+ when "ping", "query_git_commit_info"
235
+ nil
245
236
  when "help"
246
- command_class = find_builtin_command_class("Help")
247
- full_command_name = command_class.full_command_name
248
-
249
- inputs = { request: }
250
- transformed_command_class = transformed_command_from_name(full_command_name) ||
251
- transform_command_class(command_class)
237
+ { request: }
252
238
  when "list"
253
- command_class = find_builtin_command_class("ListCommands")
254
-
255
- full_command_name = command_class.full_command_name
256
-
257
- request.command_class = command_class
258
- inputs = request.inputs.merge(request:)
259
-
260
- transformed_command_class = transformed_command_from_name(full_command_name) ||
261
- transform_command_class(command_class)
239
+ request.inputs.merge(request:)
262
240
  else
263
241
  # :nocov:
264
242
  raise InvalidContextError.new(message: "Not sure what to do with #{action}")
265
243
  # :nocov:
266
244
  end
245
+ end
246
+
247
+ def request_to_command_instance(request)
248
+ command_class = request.command_class
249
+ inputs = request.inputs
267
250
 
268
251
  if inputs && !inputs.empty?
269
- transformed_command_class.new(inputs)
252
+ command_class.new(inputs)
270
253
  else
271
- transformed_command_class.new
254
+ command_class.new
272
255
  end
273
256
  end
274
257
 
@@ -305,6 +288,7 @@ module Foobara
305
288
  command = response.command
306
289
 
307
290
  if command.respond_to?(:serialize_result)
291
+ # TODO: Get serialization off of the command instance!!
308
292
  response.body = command.serialize_result(response.body)
309
293
  end
310
294
  end
@@ -383,18 +367,40 @@ module Foobara
383
367
  end
384
368
 
385
369
  def run_request(request)
386
- command = build_command(request)
387
-
388
- if command.respond_to?(:requires_authentication?) && command.requires_authentication?
389
- authenticate(request)
390
- end
391
-
392
- if command
393
- run_command(request)
394
- # :nocov:
395
- elsif !request.error
396
- raise "No command returned from #request_to_command"
397
- # :nocov:
370
+ command_class = determine_command_class(request)
371
+ request.command_class = command_class
372
+
373
+ return build_response(request) unless command_class
374
+
375
+ begin
376
+ request.open_transaction
377
+ request.use_transaction do
378
+ request.authenticate
379
+ request.mutate_request
380
+
381
+ inputs = request_to_command_inputs(request)
382
+ request.inputs = inputs
383
+ command = build_command_instance(request)
384
+ request.command = command
385
+
386
+ unless request.error
387
+ if command
388
+ run_command(request)
389
+ # :nocov:
390
+ else
391
+ raise "No command returned from #request_to_command"
392
+ # :nocov:
393
+ end
394
+ end
395
+ end
396
+ ensure
397
+ request.use_transaction do
398
+ if (request.response || request).outcome&.success?
399
+ request.commit_transaction_if_open
400
+ else
401
+ request.rollback_transaction
402
+ end
403
+ end
398
404
  end
399
405
 
400
406
  build_response(request)
@@ -414,33 +420,22 @@ module Foobara
414
420
  end
415
421
  end
416
422
 
417
- def authenticate(request)
418
- request_command = request.command
419
- authenticator = request_command.authenticator || self.authenticator
420
-
421
- request_command.after_load_records do |command:, **|
422
- authenticated_user, authenticated_credential = authenticator.authenticate(request)
423
-
424
- # TODO: why are these on the command instead of the request??
425
- request_command.authenticated_user = authenticated_user
426
- request_command.authenticated_credential = authenticated_credential
427
-
428
- unless authenticated_user
429
- request_command.outcome = Outcome.error(CommandConnector::UnauthenticatedError.new)
430
-
431
- command.state_machine.error!
432
- command.halt!
433
- end
423
+ def build_command_instance(request)
424
+ command = request_to_command_instance(request)
425
+ request.command = command
426
+ if command.is_a?(TransformedCommand)
427
+ # This allows the command to access the authenticated_user
428
+ command.request = request
434
429
  end
430
+
431
+ command
435
432
  end
436
433
 
437
- def build_command(request)
434
+ def determine_command_class(request)
438
435
  unless request.error
439
- command = request_to_command(request)
440
- request.command = command
436
+ command_class = request_to_command_class(request)
437
+ request.command_class = command_class
441
438
  end
442
-
443
- command
444
439
  end
445
440
 
446
441
  def build_response(request)
@@ -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)
@@ -11,7 +11,7 @@ module Foobara
11
11
  # Is there maybe prior art for this in the associations stuff?
12
12
  object.primary_key
13
13
  when DetachedEntity
14
- if declaration_data[:detached_to_primary_key]
14
+ if detached_to_primary_key?
15
15
  object.primary_key
16
16
  else
17
17
  object.attributes
@@ -28,6 +28,13 @@ module Foobara
28
28
  object
29
29
  end
30
30
  end
31
+
32
+ def detached_to_primary_key?
33
+ return true unless declaration_data.is_a?(::Hash)
34
+ return true unless declaration_data.key?(:detached_to_primary_key)
35
+
36
+ declaration_data[:detached_to_primary_key]
37
+ end
31
38
  end
32
39
  end
33
40
  end
@@ -95,7 +95,9 @@ module Foobara
95
95
 
96
96
  command_class.inputs_type
97
97
  else
98
- inputs_transformer.from_type || command_class.inputs_type
98
+ if inputs_transformer.is_a?(TypeDeclarations::TypedTransformer)
99
+ inputs_transformer.from_type
100
+ end || command_class.inputs_type
99
101
  end
100
102
  else
101
103
  command_class.inputs_type
@@ -479,8 +481,7 @@ module Foobara
479
481
  end
480
482
  end
481
483
 
482
- attr_accessor :command, :untransformed_inputs, :transformed_inputs, :outcome, :authenticated_user,
483
- :authenticated_credential
484
+ attr_accessor :command, :untransformed_inputs, :transformed_inputs, :outcome, :request
484
485
 
485
486
  def initialize(untransformed_inputs = {})
486
487
  self.untransformed_inputs = untransformed_inputs || {}
@@ -499,7 +500,6 @@ module Foobara
499
500
  :errors_transformers,
500
501
  :pre_commit_transformers,
501
502
  :serializers,
502
- :requires_authentication,
503
503
  :allowed_rule,
504
504
  :authenticator,
505
505
  to: :class
@@ -508,14 +508,19 @@ module Foobara
508
508
  apply_allowed_rule
509
509
  apply_pre_commit_transformers
510
510
  run_command
511
- # TODO: do this within the transaction!!!
511
+ # this gives us primary keys
512
+ flush_transactions
512
513
  transform_outcome
513
514
 
514
515
  outcome
515
516
  end
516
517
 
517
- def requires_authentication?
518
- !!requires_authentication
518
+ def authenticated_user
519
+ request.authenticated_user
520
+ end
521
+
522
+ def authenticated_credential
523
+ request.authenticated_credential
519
524
  end
520
525
 
521
526
  def transform_inputs
@@ -669,6 +674,10 @@ module Foobara
669
674
  outcome.errors
670
675
  end
671
676
 
677
+ def flush_transactions
678
+ request.opened_transactions&.reverse&.each(&:flush!)
679
+ end
680
+
672
681
  def transform_outcome
673
682
  if outcome.success?
674
683
  # can we do this while still in the transaction of the command???
@@ -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
@@ -2,6 +2,21 @@ module Foobara
2
2
  class Entity < DetachedEntity
3
3
  module SensitiveTypeRemovers
4
4
  class Entity < DetachedEntity::SensitiveTypeRemovers::DetachedEntity
5
+ def transform(strict_type_declaration)
6
+ new_type_declaration = super
7
+
8
+ if strict_type_declaration != new_type_declaration
9
+ if new_type_declaration[:type] == :entity
10
+ new_type_declaration[:type] = :detached_entity
11
+
12
+ if new_type_declaration[:model_base_class] == "Foobara::Entity"
13
+ new_type_declaration[:model_base_class] = "Foobara::DetachedEntity"
14
+ end
15
+ end
16
+ end
17
+
18
+ new_type_declaration
19
+ end
5
20
  end
6
21
  end
7
22
  end