foobara 0.1.8 → 0.1.9

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: 497323362ef9b9bcf4a7d17cb9400b84701e73dc464f3ff318e6a52b6ee3bbf6
4
- data.tar.gz: ee7bc81ea47e850b90e569c4295bd914832c3604277790edd6db153e143515a6
3
+ metadata.gz: 6f058e7ba0dd38cc79d4fa591be119decc9fa12e8d2e9b94de732d01636072b7
4
+ data.tar.gz: 71b3f8faf719fb02fc21a56a1feec8b506de34cc022244166158ed4b8482842c
5
5
  SHA512:
6
- metadata.gz: acc9a5fed9bdfa6f7c19d74652b6c2bf770a24c17880968dc476289d2231ea51b906c538ee3d10dc65365c74d9d97f9f747ae3c97400789ce30e60babc9ca6b2
7
- data.tar.gz: 03225ae2b838efc6816fe072b0f94ea6193552bb1253159aaa749ec471c18d4ea821c399cba711f6f6246cf1c38686d398bb4cd5c6385daebf91014a3ab88436
6
+ metadata.gz: 8a928e7ff495266da1595fd702fe2f1d790de3e2fb21df0f4c0ea410a53766c00e724a7ea7c2da31d4be7d77dc9068d78ff77cee95a6945e03a0a81664b12d5c
7
+ data.tar.gz: 8e70ae9f7fb74d23ab80e99854b318246c61a104ca86c4ef7a031437aa9878dd9213eb7bd952576bb111e7bdf84171f7e2141b959eb604c7bf81e733954ea329
data/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- # [0.1.8] - 2025-08-25
1
+ # [0.1.9] - 2025-09-08
2
+
3
+ - Support passing load_paths: to Entity.load to pre-load certain associations
4
+
5
+ # [0.1.8] - 2025-09-05
2
6
 
3
7
  - Memoize various parts of Type
4
8
  - Eliminate DoesNotNeedCastIf* processors
@@ -31,6 +31,7 @@ module Foobara
31
31
  key.to_s_type
32
32
  end
33
33
 
34
+ # TODO: flip these arguments?
34
35
  def values_at(data_path, object)
35
36
  unless data_path.is_a?(DataPath)
36
37
  data_path = new(data_path)
@@ -44,16 +44,40 @@ module Foobara
44
44
  current_transaction_table.find_many_by(attributes)
45
45
  end
46
46
 
47
- def load(record)
48
- if record.is_a?(Foobara::Entity)
49
- if record.loaded?
50
- record
47
+ def load(record, load_paths: nil)
48
+ record = if record.is_a?(Foobara::Entity)
49
+ if record.loaded?
50
+ record
51
+ else
52
+ current_transaction_table.load(record)
53
+ end
54
+ else
55
+ current_transaction_table.load(record)
56
+ end
57
+
58
+ if load_paths
59
+ if load_paths.is_a?(::Array)
60
+ first = load_paths.first
61
+
62
+ if first.is_a?(::Symbol) || (first.is_a?(::String) && !first.include?("."))
63
+ load_paths = [load_paths]
64
+ end
51
65
  else
52
- current_transaction_table.load(record)
66
+ load_paths = [load_paths]
67
+ end
68
+
69
+ load_paths.each do |data_path|
70
+ DataPath.values_at(data_path, record).each do |value|
71
+ if value.is_a?(Foobara::Entity)
72
+ value.class.load(value)
73
+ elsif value.is_a?(::Array)
74
+ value.each { |r| r.class.load(r) }
75
+ end
76
+ end
53
77
  end
54
- else
55
- current_transaction_table.load(record)
56
78
  end
79
+
80
+ record
57
81
  rescue ::Foobara::Persistence::EntityAttributesCrudDriver::Table::CannotFindError
58
82
  primary_key = if record.is_a?(Foobara::Entity)
59
83
  record.primary_key
data/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Foobara
2
2
  module Version
3
- VERSION = "0.1.8".freeze
3
+ VERSION = "0.1.9".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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi