tramway-core 1.17.2 → 1.17.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: 63c3cd63ade145dc9d56b1ed79122789322b6956273157b8d81a65ee8b9107af
|
4
|
+
data.tar.gz: 36e9210fe35bd7e33d218b786354b71a2ad1a316cb33252345a3ae5b49a5b6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f95be747fa6d661b575968a76053a0cee7092460d1ae919aa055f4db7a18b1fa9810a1bd76d5c2af4f667b379a836c95461e7c7060ef9f1aeb16a8f5bfe9515
|
7
|
+
data.tar.gz: a2e82ebb362b3d275aa4bec8e16c49ad6946dd36af98fb9dc5b09251a0b54178ce8115a5e1fe2cff8b121b99f06ed4d4f4579ee9317cb4cc64f85e19e91a69ca
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Tramway::Core::Associations::ClassHelper
|
2
4
|
def decorate_association(association_name, decorator: nil, as: nil, state_machines: [])
|
3
5
|
@@decorated_associations ||= []
|
@@ -23,8 +25,6 @@ module Tramway::Core::Associations::ClassHelper
|
|
23
25
|
decorate_association association_name
|
24
26
|
end
|
25
27
|
end
|
26
|
-
|
27
|
-
|
28
28
|
def define_main_association_method(association_name, decorator)
|
29
29
|
define_method association_name do
|
30
30
|
association = object.class.reflect_on_association(association_name)
|
@@ -33,7 +33,7 @@ module Tramway::Core::Associations::ClassHelper
|
|
33
33
|
raise error.message
|
34
34
|
end
|
35
35
|
decorator_class_name = decorator || "#{class_name(association).to_s.singularize}Decorator".constantize
|
36
|
-
if association.class.in? [
|
36
|
+
if association.class.in? [ActiveRecord::Reflection::HasManyReflection, ActiveRecord::Reflection::HasAndBelongsToManyReflection]
|
37
37
|
return object.send(association_name).active.map do |association_object|
|
38
38
|
decorator_class_name.decorate association_object
|
39
39
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Tramway::Core::Associations::ObjectHelper
|
2
4
|
def class_name(association)
|
3
5
|
if association.polymorphic?
|
4
|
-
object.send(
|
6
|
+
object.send(association.name).class
|
5
7
|
else
|
6
8
|
unless association.options[:class_name]
|
7
9
|
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}'`")
|
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.17.2
|
4
|
+
version: 1.17.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: audited
|