tramway-core 1.11.1 → 1.11.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08d6ae73913d795796280bd95921fd183b9c5931ad108ead009b16b78989d5fe'
|
4
|
+
data.tar.gz: 750b88db7c70b119c282a0f59d6f67f3b5cd82f1a8783eab48aff5223095d5f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b68b0b2247476b927ba050b4256926b9698453fbe38fb7eaa97d37c219da9f3307407c989c101746b254b7ccbf968599fb9446baf0c09472dc2464258dc70a5
|
7
|
+
data.tar.gz: d49b32f30fb6e1c33c6890c3aa610b2a1f93d32e71207622fb2e8b0b486a7296c553908f6cccc099b0d58701ab70f2f0bdddcdc69f6d62899c5ddad0cf70e186
|
@@ -51,15 +51,25 @@ class Tramway::Core::ApplicationDecorator
|
|
51
51
|
@@decorated_associations << association_name
|
52
52
|
|
53
53
|
define_method association_name do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
association = object.class.reflect_on_association(association_name)
|
55
|
+
class_name = if association.polymorphic?
|
56
|
+
object.send(association_name).class
|
57
|
+
else
|
58
|
+
unless association.options[:class_name]
|
59
|
+
error = Tramway::Error.new(plugin: :core, method: :decorate_association, message: ("Please, specify `#{association_name}` association class_name in #{object.class} model. For example: `has_many :#{association_name}, class_name: '#{association_name.to_s.singularize.camelize}'`"))
|
60
|
+
raise error.message
|
61
|
+
end
|
62
|
+
association.options[:class_name]
|
63
|
+
end
|
64
|
+
decorator_class_name = decorator || "#{class_name.to_s.singularize}Decorator".constantize
|
65
|
+
# FIXME rails has_many association don't have belongs_to? method... bullshit. Need PR to rails
|
66
|
+
if association.try :has_many?
|
67
|
+
object.send(association_name).active.map do |association_object|
|
68
|
+
decorator_class_name.decorate association_object
|
69
|
+
end
|
58
70
|
end
|
59
|
-
|
60
|
-
|
61
|
-
decorator_class_name = decorator || "#{class_name.singularize}Decorator".constantize
|
62
|
-
decorator_class_name.decorate association_object
|
71
|
+
if association.try :belongs_to?
|
72
|
+
decorator_class_name.decorate object.send association_name
|
63
73
|
end
|
64
74
|
end
|
65
75
|
end
|
@@ -128,4 +138,7 @@ class Tramway::Core::ApplicationDecorator
|
|
128
138
|
def object
|
129
139
|
@object
|
130
140
|
end
|
141
|
+
|
142
|
+
def association_class_name
|
143
|
+
end
|
131
144
|
end
|
data/lib/tramway/core/version.rb
CHANGED
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.11.
|
4
|
+
version: 1.11.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reform-rails
|