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: 3348ffc445ecc81aad1ca01f307174a84d0952c6a399aa261b5cf15a92a1c99a
4
- data.tar.gz: 17aa3f015b0b0b405317abe2496980ccbb736439ba312e69609782fd6f9281b4
3
+ metadata.gz: '08d6ae73913d795796280bd95921fd183b9c5931ad108ead009b16b78989d5fe'
4
+ data.tar.gz: 750b88db7c70b119c282a0f59d6f67f3b5cd82f1a8783eab48aff5223095d5f7
5
5
  SHA512:
6
- metadata.gz: b605c1f468816a86c3b8934deec966fe065a1d9bd422838fd5a93c4f7ae1759b244ac019853756a5821d678d7199aa41aedfe0984a5a11b056cedd7432d8b823
7
- data.tar.gz: 9769196d88397cb81bf2c7562ff69259e2328eb9cda0a9d2d3a4112f229265f51c850f71382350a648370c2d6f2dc7959a01d4b8c5e436614810dc1354bfd86f
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
- class_name = object.class.reflect_on_association(association_name).options[:class_name]
55
- unless class_name
56
- 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}'`"))
57
- raise error.message
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
- object.send(association_name).active.map do |association_object|
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
@@ -32,6 +32,10 @@ module Tramway
32
32
  super attribute_name
33
33
  end
34
34
  end
35
+
36
+ def search_by(*attributes, **associations)
37
+ pg_search_scope :full_text_search, against: attributes, associated_against: associations
38
+ end
35
39
  end
36
40
 
37
41
  # FIXME detect inhertited locales
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Core
3
- VERSION = '1.11.1'
3
+ VERSION = '1.11.2'
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.11.1
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-07 00:00:00.000000000 Z
11
+ date: 2019-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform-rails