foobara 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3eea1befe835410f5c6ecc372c5db94e3641f90711a773b0a7685a18afe677f
4
- data.tar.gz: 7fe5e33084023a8d475e0fe491520a179d9123b5109c0ebc2ad52ed5643752bd
3
+ metadata.gz: c106dcffef98c13b230ca60f3433638583db9c1d6a9779995baa073cc1ddff00
4
+ data.tar.gz: 4159835c178cf602fd7fdedd20d5ed030f37dfb5721b6806847f12dbaa7379cd
5
5
  SHA512:
6
- metadata.gz: 67bbdfab3b295bbe38f39d978f2855a239092f9feba4a417bbb853759dae9527dcbd0ba3a34647925f2b90fc15693c03ddb56a5d5e9247678c22c236deedba2c
7
- data.tar.gz: bc09a9a484f9c1e6487a7ce112e33aabb5132b77071f195ed06cafb79895c070ee895be8e3cdd01abf75c4fc4eb54c51dd23d0bd4b22f7d1e0ef3b584c5874d7
6
+ metadata.gz: d352b2e66aa89e993a741da14506decbc13bcde49a71d23225349b409f8871aaf9216c4a6ec38e325adace318ef01a90b078b596bed15df39cc3422fd2b59dbf
7
+ data.tar.gz: 3bf9fd820cddfaf432c704df09797ce100084507b450df4de8d2bcc4c0294ca77f5009ba51d750a7fb66161108e953a323fa7482ef35b56e6139e1acc8d90948
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # [0.1.7] - 2025-08-25
2
+
3
+ - Go back to using :detached_entity for entities that have had sensitive types removed to
4
+ avoid casting problems with multiple entities with the same name
5
+ - Remove private attributes as if they were sensitive attributes when exposing models
6
+
1
7
  # [0.1.6] - 2025-08-25
2
8
 
3
9
  - Allow constructing a thunk-like record when removing sensitive values from a thunk
@@ -7,14 +7,13 @@ module Foobara
7
7
 
8
8
  if strict_type_declaration != new_type_declaration
9
9
  if new_type_declaration[:type] == :entity
10
- if Namespace.current.foobara_root_namespace == Namespace.global.foobara_root_namespace
11
- # Nervous about creating two entities with the same name in the same namespace
12
- # So going to create a detached entity instead
13
- new_type_declaration[:type] = :detached_entity
10
+ # It's important that we don't create another entity with different attributes
11
+ # or various things like crud drivers or type transformers can become confused.
12
+ # So we will create it as a detached_entity instead.
13
+ new_type_declaration[:type] = :detached_entity
14
14
 
15
- if new_type_declaration[:model_base_class] == "Foobara::Entity"
16
- new_type_declaration[:model_base_class] = "Foobara::DetachedEntity"
17
- end
15
+ if new_type_declaration[:model_base_class] == "Foobara::Entity"
16
+ new_type_declaration[:model_base_class] = "Foobara::DetachedEntity"
18
17
  end
19
18
  end
20
19
  end
@@ -8,7 +8,7 @@ module Foobara
8
8
  elsif record.persisted?
9
9
  # We will assume that we do not need to clean up the primary key itself as
10
10
  # we will assume we don't allow sensitive primary keys for now.
11
- thunkish = to_type.target_class.build(record.class.primary_key_attribute => record.primary_key)
11
+ thunkish = to_type.target_class.send(build_method, record.class.primary_key_attribute => record.primary_key)
12
12
  thunkish.skip_validations = true
13
13
  thunkish.mutable = false
14
14
  thunkish
@@ -20,7 +20,14 @@ module Foobara
20
20
  end
21
21
 
22
22
  def build_method
23
- :build
23
+ if to_type.extends?(BuiltinTypes[:entity])
24
+ # TODO: figure out a way to test this path
25
+ # :nocov:
26
+ :build
27
+ # :nocov:
28
+ else
29
+ :new
30
+ end
24
31
  end
25
32
  end
26
33
  end
@@ -116,6 +116,12 @@ module Foobara
116
116
  def has_sensitive_types?
117
117
  return true if sensitive?
118
118
 
119
+ # TODO: this is a hack... come up with a better/separate way to detect types with private attributes
120
+ if declaration_data.is_a?(::Hash)
121
+ private = declaration_data[:private]
122
+ return true if private.is_a?(::Array) && !private.empty?
123
+ end
124
+
119
125
  if element_type
120
126
  return true if element_type.has_sensitive_types?
121
127
  end
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Foobara
2
2
  module Version
3
- VERSION = "0.1.6".freeze
3
+ VERSION = "0.1.7".freeze
4
4
  MINIMUM_RUBY_VERSION = ">= 3.4.0".freeze
5
5
  end
6
6
  end
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.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi