foobara 0.0.15 → 0.0.17

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: 89c535ec7934bbfbe1a665f068ada534300095d5224c81315e7ca60d84e50459
4
+ data.tar.gz: 7900c49115eace2fbbc7c35e1516c29ca4831763268ea130ce9aecc2b841f53f
5
5
  SHA512:
6
- metadata.gz: f869b1e7749e1388c86de79964d0031eb0bddb00eea9c477bc8336aa41d2941571dceaa506a16fbd9f8dee479e2cf6e708542fb938bae3cc295d8dddc4909a29
7
- data.tar.gz: 7755a9dfe9587cbcf7726ba1d25397012e31a6123efa97c8141b63d703c42af56df007d4fd22e604da0b1f05d4f2d84e3484f718c00d917863803921d47aecd7
6
+ metadata.gz: 31ae262884a960219e3f738ac50706d36eb44f8336bbf56741f0b66387270201c36fa83fecba3531a6d46f7cbb5187d4a6693058f06b7186481e043a1ce981da
7
+ data.tar.gz: '08d1a902c9948229402dcf23df1279e90ad4c3668c2e9270e8199c07c4978ddb744d4b3de702d0e3661141c11a16d8e7f9a6dc884ced1e98b245650a669eb2ca'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.0.17] - 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
+ - Add a Transaction#perform convenience method
6
+
1
7
  ## [0.0.15] - 2024-11-20
2
8
 
3
9
  - 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
@@ -157,6 +157,11 @@ module Foobara
157
157
  def flush_created_record!(record)
158
158
  table_for(record).flush_created_record!(record)
159
159
  end
160
+
161
+ # convenience method...
162
+ def perform(&)
163
+ entity_base.using_transaction(self, &)
164
+ end
160
165
  end
161
166
  end
162
167
  end
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.17
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