effective_resources 1.4.6 → 1.4.7
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: 97764ee0170d441cf4e7c5f1c19dfd934725a44ef8989a62c3ea0489c964f9f5
|
4
|
+
data.tar.gz: b0ad99c6f0ec0ed3646749acba55682d6598dc03ab6fad18afaa7b86a992f97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f9cb800b96d5e537f9ed9a015daa19f0a12626855d1f68aad9c845befbb2fc4ad8bbcaacac5ebbed4c384a3b603ee359308a423b3ff27080a0fcf4dc17180d1
|
7
|
+
data.tar.gz: fa827846f103b4c1113e74670898d79e586cb4c624d58ee0339c28c023456a2be3a3fe5554d47769d6f483b1ad4fbe4b2f6a009b3e097e8c1efaa1ae3ec1af9a
|
@@ -60,6 +60,7 @@ module Effective
|
|
60
60
|
when :effective_addresses ; :effective_addresses
|
61
61
|
when :effective_obfuscation ; :effective_obfuscation
|
62
62
|
when :effective_roles ; :effective_roles
|
63
|
+
when :active_storage ; :active_storage
|
63
64
|
else
|
64
65
|
raise "unsupported type for #{obj}"
|
65
66
|
end
|
@@ -137,6 +138,8 @@ module Effective
|
|
137
138
|
value.to_s
|
138
139
|
end
|
139
140
|
end
|
141
|
+
when :active_storage
|
142
|
+
value.to_s
|
140
143
|
else
|
141
144
|
raise "unsupported type #{type}"
|
142
145
|
end
|
@@ -43,6 +43,11 @@ module Effective
|
|
43
43
|
klass.reflect_on_all_associations(:has_and_belongs_to_many)
|
44
44
|
end
|
45
45
|
|
46
|
+
def active_storages
|
47
|
+
return [] unless klass.respond_to?(:reflect_on_all_associations)
|
48
|
+
klass.reflect_on_all_associations.select { |ass| ass.class_name == 'ActiveStorage::Attachment' }
|
49
|
+
end
|
50
|
+
|
46
51
|
def active_storage_has_manys
|
47
52
|
return [] unless klass.respond_to?(:reflect_on_all_associations)
|
48
53
|
klass.reflect_on_all_associations(:has_many).select { |ass| ass.class_name == 'ActiveStorage::Attachment' }
|
@@ -118,6 +123,11 @@ module Effective
|
|
118
123
|
Effective::Address.where(category: category).where(addressable_type: class_name)
|
119
124
|
end
|
120
125
|
|
126
|
+
def active_storage(name)
|
127
|
+
name = name.to_sym
|
128
|
+
active_storages.find { |ass| ass.name.to_s.gsub(/_attachment(s?)\z/, '').to_sym == name }
|
129
|
+
end
|
130
|
+
|
121
131
|
def nested_resource(name)
|
122
132
|
name = name.to_sym
|
123
133
|
nested_resources.find { |ass| ass.name == name }
|
@@ -40,6 +40,9 @@ module Effective
|
|
40
40
|
relation
|
41
41
|
.order(order_by_associated_conditions(associated(:addresses), sort: sort, direction: direction, limit: limit))
|
42
42
|
.order(Arel.sql("#{sql_column(klass.primary_key)} #{sql_direction}"))
|
43
|
+
when :active_storage
|
44
|
+
relation.send("with_attached_#{name}").references("#{name}_attachment")
|
45
|
+
.order(Arel.sql("active_storage_blobs.filename #{sql_direction}"))
|
43
46
|
when :effective_roles
|
44
47
|
relation.order(Arel.sql("#{sql_column(:roles_mask)} #{sql_direction}"))
|
45
48
|
when :string, :text
|
@@ -101,6 +104,9 @@ module Effective
|
|
101
104
|
relation.where("#{sql_column} = ?", (value == term ? 0 : term))
|
102
105
|
when :effective_roles
|
103
106
|
relation.with_role(term)
|
107
|
+
when :active_storage
|
108
|
+
relation.send("with_attached_#{name}").references("#{name}_attachment")
|
109
|
+
.where(ActiveStorage::Blob.arel_table[:filename].matches("%#{term}%"))
|
104
110
|
when :boolean
|
105
111
|
relation.where("#{sql_column} = ?", term)
|
106
112
|
when :datetime, :date
|
@@ -52,6 +52,8 @@ module Effective
|
|
52
52
|
:belongs_to_polymorphic
|
53
53
|
elsif has_and_belongs_to_many(name)
|
54
54
|
:has_and_belongs_to_many
|
55
|
+
elsif active_storage(name)
|
56
|
+
:active_storage
|
55
57
|
elsif name == 'id' && defined?(EffectiveObfuscation) && klass.respond_to?(:deobfuscate)
|
56
58
|
:effective_obfuscation
|
57
59
|
elsif name == 'roles' && defined?(EffectiveRoles) && klass.respond_to?(:with_role)
|
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.4.
|
4
|
+
version: 1.4.7
|
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: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|