foobara 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cec596f3e023a3bb6381c2f4406f6419d15cdeae3b9b1c7140a74ea8d999b4e4
4
- data.tar.gz: 7d493bb518a6892cbc483bbdedaa0301e2986a8c90d03249dd9abf2210b52032
3
+ metadata.gz: a386511b5dd07ad9a067ce02cdf7dfef7436a9db51fe938e26e1dec2c42b836f
4
+ data.tar.gz: bf3f4960d49e6ca8f9a17ee7f4ceb7d3f04dd433172bc0028d8314081c933049
5
5
  SHA512:
6
- metadata.gz: f869b1e7749e1388c86de79964d0031eb0bddb00eea9c477bc8336aa41d2941571dceaa506a16fbd9f8dee479e2cf6e708542fb938bae3cc295d8dddc4909a29
7
- data.tar.gz: 7755a9dfe9587cbcf7726ba1d25397012e31a6123efa97c8141b63d703c42af56df007d4fd22e604da0b1f05d4f2d84e3484f718c00d917863803921d47aecd7
6
+ metadata.gz: 7cd69b5365baa7bb77534875bed988c638b2c48d79d28119337adca49c8a2551bd958bd3835da682fc143d57186ba7efbf8a36630fc573d0991ae0c10c4cf6bb
7
+ data.tar.gz: e00097bd3e762179bd14bfa9e292a2b93c6f063d5dd67b82ec6942d7578af206dd97322a560a7f0e9771bb5b799d2acb34d07e08db4d3f46f6f22ab48f2be642
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.0.16] - 2024-11-22
2
+
3
+ - Fix bug where mutable not being set explicitly raises
4
+ - Also, make it so models don't default to mutable false when processed by a model type
5
+
1
6
  ## [0.0.15] - 2024-11-20
2
7
 
3
8
  - Move entity attributes type declaration helpers from Command::EntityHelpers to Entity for convenience.
@@ -2,6 +2,7 @@ module Foobara
2
2
  module BuiltinTypes
3
3
  module Entity
4
4
  module Casters
5
+ # TODO: We need a way of disabling/enabling this and it should probably be disabled by default.
5
6
  class Hash < Attributes::Casters::Hash
6
7
  class << self
7
8
  def requires_parent_declaration_data?
@@ -11,11 +11,19 @@ module Foobara
11
11
  end
12
12
 
13
13
  def transform(record)
14
- record.mutable = if parent_declaration_data.key?(:mutable)
15
- parent_declaration_data[:mutable]
16
- else
17
- false
18
- end
14
+ if parent_declaration_data.key?(:mutable)
15
+ # hmmmm.... can we really just arbitrarily clobber this?
16
+ # wouldn't that be surprising to calling code that passes in a record/model?
17
+ # One use-case of this seems to be to reduce the amount of possible errors a command reports
18
+ # by declaring that only some subset or none of the attributes are mutable.
19
+ # However, we shouldn't react to this by clobbering the mutable state of the record because it might not
20
+ # be a fresh record fetched from a primary key it might be an already loaded record/model from some other
21
+ # context and that context might be surprised to learn that we've clobbered its mutability status.
22
+ # Solutions?
23
+ # 1. In the case of models, we could duplicate the model if the mutable value is different.
24
+ # 2. But what about entities? We almost need some sort of proxy entity that tightens the mutability?
25
+ record.mutable = parent_declaration_data[:mutable]
26
+ end
19
27
 
20
28
  record
21
29
  end
@@ -207,6 +207,7 @@ module Foobara
207
207
  end
208
208
  end
209
209
 
210
+ # why do we default to true here but false in the transformers?
210
211
  mutable = options.key?(:mutable) ? options[:mutable] : true
211
212
 
212
213
  self.mutable = if mutable.is_a?(::Array)
@@ -227,7 +228,7 @@ module Foobara
227
228
  def write_attribute(attribute_name, value)
228
229
  attribute_name = attribute_name.to_sym
229
230
 
230
- if mutable == true || mutable.include?(attribute_name)
231
+ if mutable == true || mutable&.include?(attribute_name)
231
232
  outcome = cast_attribute(attribute_name, value)
232
233
  attributes[attribute_name] = outcome.success? ? outcome.result : value
233
234
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-20 00:00:00.000000000 Z
11
+ date: 2024-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara-util