activerecord-bixformer 0.4.4 → 0.4.5

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
  SHA1:
3
- metadata.gz: 7fb89bcee1a68dc2fa2dc3b9be84e4d5720ff8db
4
- data.tar.gz: 397f458b9bb776d27f195b0a702905b1cb0506d6
3
+ metadata.gz: 975aa8d7deb6a1db994d840cef88a84548505449
4
+ data.tar.gz: 18b1ef10ebe9d3a1973468ff4de5899769db39e6
5
5
  SHA512:
6
- metadata.gz: 96adb2970166144d0b9990a6d87e86a644f323f1f45450addb342a98c16631bc84091cd82bfb11a9b044e8a898d30384dd8cc0d3830ada53e1d1e61ecdb106d3
7
- data.tar.gz: e629bb57d0c732495c8ecc304fa2a34f4c658918665dfbba4074b2566cd317190e7d57f36d4d67a0de3b167bec0b7ac85c502a962e6eb5c7cea0586b034985ff
6
+ metadata.gz: 0e29358781db9fc618679e1f82816bcdfbbb91527df9a19037058f2ae0bb4007744b97151b0a9a7b76cf0d5c45e2bcfd105a81e8da246b74dfea21b45f864b68
7
+ data.tar.gz: ecc108217d93c7c574d2df66f143e45ed905abe266772ebc6f11358784625fa4dc41008652edf67e5f7ca3a2501e26f199a7ea7885710e09b492a059d8e70286
@@ -80,9 +80,15 @@ module ActiveRecord
80
80
  private
81
81
 
82
82
  def foreign_constant
83
- @foreign_constant ||= @model.activerecord_constant
84
- .reflections.values.find { |r| r.foreign_key == @name }
85
- .table_name.classify.constantize
83
+ @foreign_constant ||= -> do
84
+ reflection = @model.activerecord_constant.reflections.values.find { |r| r.foreign_key == @name }
85
+
86
+ if reflection.respond_to?(:class_name)
87
+ reflection.class_name.constantize
88
+ else
89
+ reflection.table_name.classify.constantize
90
+ end
91
+ end.call
86
92
  end
87
93
  end
88
94
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Bixformer
3
- VERSION = "0.4.4"
3
+ VERSION = "0.4.5"
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.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroaki Otsu