tramway-core 4.0.2 → 4.0.2.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071cf2ccd054e5bde3e9ecc232476ec1a48d2aa4e3d51246befdd770a6e89876
|
4
|
+
data.tar.gz: 7aa40b3777e070784dd0f0ca57baf12b4fd6378e5911b1e3dfa25ec6b427e24f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ff54066670f690934e828bd599b8cbeac5ad3cf27c43d2d56f54425f0bbf38708ae9d0bea74983d35a8b08a6a5393ed88810bd5e37672290653293dcb170919
|
7
|
+
data.tar.gz: 521157e341cc6eada7c4c1c4e97b620e5233dc28d15adbe148d53daa0b397d138b4084d69228379cd6a1e45e5fe7bf065f19181080f23d3ee00fc828b4bf8636
|
@@ -14,14 +14,16 @@ module Tramway::Core::ApplicationForms::AssociationObjectHelpers
|
|
14
14
|
|
15
15
|
def define_polymorphic_association(association, _class_name)
|
16
16
|
self.class.send(:define_method, "#{association}=") do |value|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
if value.present?
|
18
|
+
association_class = value.split('_')[0..-2].join('_').camelize
|
19
|
+
association_class = association_class.constantize if association_class.is_a? String
|
20
|
+
if association_class.nil?
|
21
|
+
Tramway::Error.raise_error :tramway, :core, :application_form, :initialize, :polymorphic_class_is_nil,
|
22
|
+
association_name: association
|
23
|
+
else
|
24
|
+
model.send "#{association}=", association_class.find(value.split('_')[-1])
|
25
|
+
send "#{association}_type=", association_class.to_s
|
26
|
+
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/tramway/core/version.rb
CHANGED