activerecord-bixformer 0.4.17 → 0.4.18

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
  SHA1:
3
- metadata.gz: 078c30908de9e4bc0604a1d62bfff820a57644d9
4
- data.tar.gz: 4122a19b05d79688b8862576f516b82ebf3667b4
3
+ metadata.gz: ae6888312a21e7d9354ae7c46e4b8fc9e87aa4c2
4
+ data.tar.gz: bb36394798a5fa42d748f1c2a50ca8ea8fe19fa0
5
5
  SHA512:
6
- metadata.gz: 3a95d90a738354a0824b3194af7791c2fb2b51cd906cb245dec548239079a3869fa213a6500141113752888c1ee104b98f1d75341c722a39f1ce3e57174867a2
7
- data.tar.gz: 13ec0040a6f143908150e80ae9b5a92124a5c6ec66a2919da9f4b52a9e67a47c7e9deda0d3f0751e49b7b737de1006e8c24b3f596143a0819d2e089f0cdb2b49
6
+ metadata.gz: 1995b2cb22b6f1569df73e0b284af26926e2425170a7be0e6db97b6efab7d20f21129960f2165ca09376c2853a5fd13878e8a320b1e9bf07e7b85abb37bb3044
7
+ data.tar.gz: a7d635b60db5b21c39640f455a380e07401ba241c078548793be9b7a780a0d5f5b82d76f1761269e68814cdf0662c87d5a1416f839ed50e5cde0cde85557b214
@@ -42,10 +42,6 @@ module ActiveRecord
42
42
  private
43
43
 
44
44
  def do_export(record_or_relation)
45
- if record_or_relation.is_a?(::ActiveRecord::Relation)
46
- record_or_relation = record_or_relation.where(@plan.pickup_value_for(self, :required_condition, {}))
47
- end
48
-
49
45
  values = run_bixformer_callback :export, type: :attribute do
50
46
  # has_one でしか使わない想定なので record_or_relation は ActiveRecord::Base のはず
51
47
  @attributes.map do |attr|
@@ -61,13 +57,21 @@ module ActiveRecord
61
57
 
62
58
  run_bixformer_callback :export, type: :association do
63
59
  @associations.inject(values) do |each_values, association|
64
- association_value = if record_or_relation
65
- run_bixformer_callback :export, on: association.name do
66
- record_or_relation.__send__(association.name)
67
- end
68
- end
60
+ association_value =
61
+ if record_or_relation
62
+ run_bixformer_callback :export, on: association.name do
63
+ association_record_or_relation = record_or_relation.__send__(association.name)
64
+
65
+ if association_record_or_relation.is_a?(::ActiveRecord::Relation)
66
+ association_record_or_relation =
67
+ association_record_or_relation.where(@plan.pickup_value_for(association, :required_condition, {}))
68
+ end
69
+
70
+ association.export(association_record_or_relation)
71
+ end
72
+ end
69
73
 
70
- each_values.merge(association.export(association_value))
74
+ each_values.merge(association_value || {})
71
75
  end
72
76
  end
73
77
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Bixformer
3
- VERSION = "0.4.17"
3
+ VERSION = "0.4.18"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-bixformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.17
4
+ version: 0.4.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroaki Otsu