effective_resources 1.8.32 → 1.8.36
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: 06f8572e4cacab573ff3121145f120c1844e81af1c35d57d3fa9d42ffd819338
|
4
|
+
data.tar.gz: c168aa140a18323a17132c25d16edd3fb88329738f63c1a4dcfe7d66bde6ec6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5043556b5414776fd0ad50ee9a298cede2ae403da26eb6cbacc4d2ccf418c71db71c22671fc5e52f378d2a0db244dd14ee45ecbf21756edcd468d0b8b22f07f2
|
7
|
+
data.tar.gz: eb2538b9526d60153db7faa8bd37eee9080001bcf268070ba2b754333213142ec90d98ba3067cb76c643f2eff988cad395d9353bdadc0a1910ed304388626054
|
@@ -62,5 +62,19 @@ module Effective
|
|
62
62
|
wizard_path(step, resource_name_id => param)
|
63
63
|
end
|
64
64
|
|
65
|
+
private
|
66
|
+
|
67
|
+
def current_step_before?(nav_step)
|
68
|
+
index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
|
69
|
+
current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
|
70
|
+
current < index
|
71
|
+
end
|
72
|
+
|
73
|
+
def current_step_after?(nav_step)
|
74
|
+
index = wizard_steps.index(nav_step) || raise("step #{nav_step} not found in wizard_steps")
|
75
|
+
current = wizard_steps.index(step) || raise("current step not found in wizard_steps")
|
76
|
+
current > index
|
77
|
+
end
|
78
|
+
|
65
79
|
end
|
66
80
|
end
|
@@ -56,7 +56,11 @@ module Effective
|
|
56
56
|
when ActiveRecord::Relation
|
57
57
|
input.klass
|
58
58
|
when (ActiveRecord::Reflection::AbstractReflection rescue :nil)
|
59
|
-
|
59
|
+
if input.options[:polymorphic]
|
60
|
+
_klass_by_name(input.class_name)
|
61
|
+
else
|
62
|
+
(input.klass rescue nil) || _klass_by_name(input.class_name)
|
63
|
+
end
|
60
64
|
when ActiveRecord::Reflection::MacroReflection
|
61
65
|
((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
|
62
66
|
when ActionDispatch::Journey::Route
|
@@ -91,9 +91,11 @@ module Effective
|
|
91
91
|
|
92
92
|
if term == 'nil'
|
93
93
|
relation.where(is_null("#{sql_column}_id")).where(is_null("#{sql_column}_type"))
|
94
|
-
elsif type.present? && id.present?
|
94
|
+
elsif type.present? && id.present? # This was from a polymorphic select
|
95
95
|
relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
|
96
|
-
|
96
|
+
elsif name == :user # Polymorphic user
|
97
|
+
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
98
|
+
else # Maybe from a string field
|
97
99
|
id ||= Effective::Attribute.new(:integer).parse(term)
|
98
100
|
relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
|
99
101
|
end
|
@@ -213,8 +215,10 @@ module Effective
|
|
213
215
|
|
214
216
|
# key: the id, or associated_id on my table
|
215
217
|
# keys: the ids themselves as per the target table
|
216
|
-
|
217
|
-
|
218
|
+
if association.macro == :belongs_to && association.options[:polymorphic]
|
219
|
+
key = sql_column(association.foreign_key)
|
220
|
+
keys = relation.pluck((relation.klass.primary_key rescue nil))
|
221
|
+
elsif association.macro == :belongs_to
|
218
222
|
key = sql_column(association.foreign_key)
|
219
223
|
keys = relation.pluck(association.klass.primary_key)
|
220
224
|
elsif association.macro == :has_and_belongs_to_many
|
@@ -289,7 +293,10 @@ module Effective
|
|
289
293
|
# key: the id, or associated_id on my table
|
290
294
|
# keys: the ids themselves as per the target table
|
291
295
|
|
292
|
-
if association.macro == :belongs_to
|
296
|
+
if association.macro == :belongs_to && association.options[:polymorphic]
|
297
|
+
key = sql_column(association.foreign_key)
|
298
|
+
keys = relation.pluck((relation.klass.primary_key rescue nil))
|
299
|
+
elsif association.macro == :belongs_to
|
293
300
|
key = sql_column(association.foreign_key)
|
294
301
|
keys = relation.pluck(association.klass.primary_key)
|
295
302
|
elsif association.macro == :has_and_belongs_to_many
|
data/lib/effective_resources.rb
CHANGED
@@ -64,4 +64,36 @@ module EffectiveResources
|
|
64
64
|
date.wday != 0 && date.wday != 6 && Holidays.on(date, *holidays).blank?
|
65
65
|
end
|
66
66
|
|
67
|
+
# https://stackoverflow.com/questions/66103388/attach-activestorage-blob-with-a-different-filename
|
68
|
+
def self.clone_blob(blob, options = {})
|
69
|
+
raise('expected an ActiveStorage::Blob') unless blob.kind_of?(ActiveStorage::Blob)
|
70
|
+
|
71
|
+
atts = {
|
72
|
+
filename: blob.filename,
|
73
|
+
byte_size: blob.byte_size,
|
74
|
+
checksum: blob.checksum,
|
75
|
+
content_type: blob.content_type,
|
76
|
+
metadata: blob.metadata,
|
77
|
+
}.merge(options)
|
78
|
+
|
79
|
+
service = blob.service
|
80
|
+
duplicate = ActiveStorage::Blob.create_before_direct_upload!(**atts)
|
81
|
+
|
82
|
+
case service.class.name
|
83
|
+
when 'ActiveStorage::Service::S3Service'
|
84
|
+
bucket = service.bucket
|
85
|
+
object = bucket.object(blob.key)
|
86
|
+
object.copy_to(bucket.object(duplicate.key))
|
87
|
+
when 'ActiveStorage::Service::DiskService'
|
88
|
+
path = service.path_for(blob.key)
|
89
|
+
duplicate_path = service.path_for(duplicate.key)
|
90
|
+
FileUtils.mkdir_p(File.dirname(duplicate_path))
|
91
|
+
FileUtils.ln(path, duplicate_path) if File.exists?(path)
|
92
|
+
else
|
93
|
+
raise "unknown storage service #{service.class.name}"
|
94
|
+
end
|
95
|
+
|
96
|
+
duplicate
|
97
|
+
end
|
98
|
+
|
67
99
|
end
|
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.8.
|
4
|
+
version: 1.8.36
|
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-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|