effective_resources 1.9.10 → 1.9.14

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: 36829df631b235ec0cb1a9cc26616fd15c100bfcb2314f57edd1a70f5eda3f86
4
- data.tar.gz: 3b93094b4d501b4d737f0011b337d806eb67305642b4bb4f2e6263672c5b9267
3
+ metadata.gz: 7fa555e65ca74d65ab0bfbeef9b7dc8817e12951daf8ae8de6328512391a61aa
4
+ data.tar.gz: 5a19481dee889d9b75d93523c2a8c8b3899c60eecb1496637cb7bf3c592f4421
5
5
  SHA512:
6
- metadata.gz: 032ca3f256846e3b666bc33f5452fb7aefefd910abc9b4c1d9f068ec04b82e6b5c61999e0107a4feb03509921b0f333ce43b9a155c2fcb04eebe7a4d955544db
7
- data.tar.gz: 2d1c59030ea9e8ec2d78efe2d5c9b15571abc0ec9f86fbc506250af2703b8ad87388e2ebc3f517c1d47101b31fcbacada059ca94bfdc51fb7d24b363121af5ad
6
+ metadata.gz: 9c7d741ba719f1255fe53a1aecd195fcc78d70d29387c4a6f2cf8b989999b69effed19e5d18336521476dfc036362ca6c9ca9a829d3832c975f976ac89362208
7
+ data.tar.gz: 2f363dd0624e8d7ab007e7e9e7446b557f1f8f311d348d4dcafeb8b99bd8cb14de50f24b0a508eae8a1c7f3b22d1c0d2aad25755caf85e649964a89a2f23fbe6
@@ -160,9 +160,7 @@ module EffectiveDeviseUser
160
160
  args.last[:tenant] ||= tenant
161
161
  end
162
162
 
163
- wait = (5 if notification == :invitation_instructions && !Rails.env.test?)
164
-
165
- devise_mailer.send(notification, self, *args).deliver_later(wait: wait)
163
+ devise_mailer.send(notification, self, *args).deliver_now
166
164
  end
167
165
 
168
166
  end
@@ -21,7 +21,11 @@ module Effective
21
21
  collection ||= (klass.const_get(constant_pluralized) rescue nil) if defined?("#{klass.name}::#{constant_pluralized}")
22
22
  end
23
23
 
24
- { as: :select, polymorphic: true, collection: (collection || []) }.compact
24
+ if collection.present?
25
+ { as: :select, polymorphic: true, collection: (collection || []) }
26
+ else
27
+ { as: :string }
28
+ end
25
29
  when :has_and_belongs_to_many
26
30
  { as: :select }.merge(search_form_field_collection(has_and_belongs_to_many(name)))
27
31
  when :has_many
@@ -98,8 +98,18 @@ module Effective
98
98
  elsif name == :user # Polymorphic user
99
99
  relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
100
100
  else # Maybe from a string field
101
- id ||= Effective::Attribute.new(:integer).parse(term)
102
- relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
101
+ collection = relation.none
102
+
103
+ relation.unscoped.distinct("#{name}_type").pluck("#{name}_type").each do |klass_name|
104
+ next if klass_name.nil?
105
+
106
+ resource = Effective::Resource.new(klass_name)
107
+ next unless resource.klass.present?
108
+
109
+ collection = collection.or(relation.where("#{name}_id": resource.search_any(term), "#{name}_type": klass_name))
110
+ end
111
+
112
+ collection
103
113
  end
104
114
  when :has_and_belongs_to_many, :has_many, :has_one
105
115
  relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.9.10'.freeze
2
+ VERSION = '1.9.14'.freeze
3
3
  end
@@ -52,11 +52,7 @@ module EffectiveResources
52
52
  end
53
53
 
54
54
  def self.transaction(resource = nil, &block)
55
- connection = (resource if resource.respond_to?(:transaction))
56
- connection ||= (resource.class if resource.class.respond_to?(:transaction))
57
- connection ||= '::ApplicationRecord'.safe_constantize
58
- connection ||= 'ActiveRecord::Base'.safe_constantize
59
-
55
+ connection = 'ActiveRecord::Base'.safe_constantize
60
56
  raise('unable to determine transaction class') unless connection.present?
61
57
 
62
58
  connection.transaction { yield }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.10
4
+ version: 1.9.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails