tramway-core 1.7.2 → 1.7.3

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: '08f6f6bcde39befd59ba6691ac7af8c9ad1c6e7b411a77a43136e48ba3bdcbec'
4
- data.tar.gz: be08d3d9cd2484c2669e514ed21c10f1c265fec09de9c37d393603f289f53af4
3
+ metadata.gz: 97cfa339940bd9067cda8cf886cfd29a82a0debb02cc8132062ba1b53cd49cfb
4
+ data.tar.gz: 17d8068d67d5030710033ce569a9baceaa9da76e230fdcc4504ceb1000f5927d
5
5
  SHA512:
6
- metadata.gz: 273c2332f4f35eb86de887b7452c67cee82acb3ebc06c351ed90edbabfe89e57ffc420c7160b3f7f93ed49c48a54892b66a58369dd0cf1a7a5928bbfc71d7d1a
7
- data.tar.gz: 0b628fc43bd379254fc06f5c2b499c454c8ffbbf902c64615b066c4548733be70f216fc10495febcb4e54accbc8d8b5f281ec17e21199cc564e20242e66dde73
6
+ metadata.gz: 4a5c9036fc2339564f53702368c4c922e87352729a7e8b3e4351c09cb93fbdfe3dad9a5216fc16f24320ddda9e5891493cc32816a3fe8b2dbe33edfa4590e062
7
+ data.tar.gz: '083b6dc46530562cbd5e1d8ece27dbee00de52da383666308c506554a54ce13939b35d18c13dc72bfcd173a6368f25958f7c3270611eb501c12811f58c22c7bb'
@@ -6,8 +6,15 @@ module Tramway::Core
6
6
  @@enumerized_attributes = object.class.enumerized_attributes
7
7
 
8
8
  self.class.full_class_name_associations.each do |association, class_name|
9
- self.class.send(:define_method, "#{association}=") do |value|
10
- super class_name.find value
9
+ if class_name.is_a? Array
10
+ self.class.send(:define_method, "#{association}=") do |value|
11
+ association_class = send("#{association}_type")
12
+ super association_class.constantize.find value
13
+ end
14
+ else
15
+ self.class.send(:define_method, "#{association}=") do |value|
16
+ super class_name.find value
17
+ end
11
18
  end
12
19
  end
13
20
  end
@@ -47,7 +54,14 @@ module Tramway::Core
47
54
  a.name == association.to_sym
48
55
  end.first&.options
49
56
 
50
- options ? hash.merge!(association => options[:class_name].constantize) : hash
57
+ if options
58
+ if options[:polymorphic]
59
+ hash.merge! association => @@model_class.send("#{association}_type").values
60
+ else
61
+ hash.merge!(association => options[:class_name].constantize)
62
+ end
63
+ end
64
+ hash
51
65
  end
52
66
  end
53
67
 
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Core
3
- VERSION = '1.7.2'
3
+ VERSION = '1.7.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-13 00:00:00.000000000 Z
11
+ date: 2018-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform-rails