lhs 24.1.0.pre.1 → 24.1.0.pre.2

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: '0098eb4147ef54ee7e80bb67e1a466c39165ef4b65ad2ac18f6a2c024ee2e9f7'
4
- data.tar.gz: 853bd4e9697debd6c559d24d295019473793c3c5bcf4c1a3f5cdba3d966a743c
3
+ metadata.gz: 5a418b290339a24c8c2551c84facfe6ace4454dfb412d73ccd4bca16b89c5539
4
+ data.tar.gz: 1f8c96a3b79392e4bdd3bfde8752b99ad37721bff564a23e2431db85469c02d8
5
5
  SHA512:
6
- metadata.gz: d3db0060e2155188d1697ec6e9c9000d05b13592d6a8ec7c5f952a28b25d1162f72c009f5f70375e06e67637a8d4e488e1946a161bda24513cbb1ea17fe626a3
7
- data.tar.gz: aa448eeb65c3b13ba529040d79b4a3cb6ac31f3961cf407e6d72d6f69bdc3dfc5f543c8d02cd1a3d4932b6a57e0c26fabbd91f365f7629676445cbc328e93e42
6
+ metadata.gz: 7cfc3e5008104bca9f6bea87c3cde06c774946c2c0d4ce56b8f9f2ab589c8d93dba506722e2ef389a48c2432c23d9353529b274930817a6204a0f7eea5d45594
7
+ data.tar.gz: 49aa488ca17924ff4c4587c5aee20247417946d719ea29dde5f3f9a155c0f6f4099f5cdb53175e82b98ae984cf4b8b5614883cb8520fd224c9a660aa966d1a02
@@ -10,6 +10,7 @@ class LHS::Data
10
10
  # Extends already fetched data (self) with additionally
11
11
  # fetched data (addition) using the given key
12
12
  def extend!(addition, key)
13
+ addition = cast_relation_class_for_extension(addition, key)
13
14
  if collection?
14
15
  extend_collection!(addition, key)
15
16
  elsif self[key]._raw.is_a? Array
@@ -21,6 +22,11 @@ class LHS::Data
21
22
 
22
23
  private
23
24
 
25
+ def cast_relation_class_for_extension(addition, key)
26
+ return addition if _record.nil? || _record._relations.nil? || _record._relations[key].nil?
27
+ addition.becomes(_record._relations[key][:record_class_name].constantize, errors: addition.errors, warnings: addition.warnings)
28
+ end
29
+
24
30
  def extend_collection!(addition, key)
25
31
  map do |item|
26
32
  item_raw = item._raw[key]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '24.1.0.pre.1'
4
+ VERSION = '24.1.0.pre.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 24.1.0.pre.1
4
+ version: 24.1.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors