effective_resources 2.18.4 → 2.19.0
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: 02dcf459be067c9b55f9ab488cbcc9f5fd34c88549c9fc3c58db5f5668496062
|
4
|
+
data.tar.gz: c0ba59be147cb88eba96c420685dcafee9e8cc48098ab9a8c878b0cf670eb1db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf45b4e61e486e8df1927c6f0b61e2c965ddd1c6c56a2a99386c6813616b81cc541d59193699d422db76f17cbd3dccf2800ec4397e367be2db46e1a7054bd9b7
|
7
|
+
data.tar.gz: a980a5d995bc8b7294e01debdd1ca7cfa5d5efc59d3462666677c2d1156f33e33471f188b1add2a6afd7759a965da5fae082bf31f825456caf6582af5fcb2478
|
@@ -83,7 +83,14 @@ module Effective
|
|
83
83
|
|
84
84
|
def resource_scope
|
85
85
|
relation = effective_resource.relation
|
86
|
-
|
86
|
+
|
87
|
+
# Apply jit_preloader if present
|
88
|
+
if defined?(JitPreloader) && EffectiveResources.use_jit_preloader
|
89
|
+
relation.includes_values = [] # Removes any previously defined .includes()
|
90
|
+
relation.jit_preload
|
91
|
+
else
|
92
|
+
(relation.try(:deep) || relation)
|
93
|
+
end
|
87
94
|
end
|
88
95
|
|
89
96
|
def resource_name # 'thing'
|
@@ -13,7 +13,7 @@ module Effective
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# called by effective_trash and effective_logging
|
16
|
-
def instance_attributes(only: nil, except: nil)
|
16
|
+
def instance_attributes(only: nil, except: nil, associations: true)
|
17
17
|
return {} unless instance.present?
|
18
18
|
|
19
19
|
# Build up our only and except
|
@@ -34,43 +34,45 @@ module Effective
|
|
34
34
|
attributes[association.name] = instance.send(association.name).to_s
|
35
35
|
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
if associations
|
38
|
+
# Grab the instance attributes of each nested resource
|
39
|
+
nested_resources.each do |association|
|
40
|
+
next if except.present? && except.include?(association.name)
|
41
|
+
next unless only.blank? || only.include?(association.name)
|
41
42
|
|
42
|
-
|
43
|
+
next if association.options[:through]
|
43
44
|
|
44
|
-
|
45
|
+
attributes[association.name] ||= {}
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
Array(instance.send(association.name)).each_with_index do |child, index|
|
48
|
+
next unless child.present?
|
48
49
|
|
49
|
-
|
50
|
-
|
50
|
+
resource = Effective::Resource.new(child)
|
51
|
+
attributes[association.name][index] = resource.instance_attributes(only: only, except: except)
|
52
|
+
end
|
51
53
|
end
|
52
|
-
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
(action_texts + has_ones).each do |association|
|
56
|
+
next if except.present? && except.include?(association.name)
|
57
|
+
next unless only.blank? || only.include?(association.name)
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
attributes[association.name] = instance.send(association.name).to_s
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
has_manys.each do |association|
|
63
|
+
next if except.present? && except.include?(association.name)
|
64
|
+
next unless only.blank? || only.include?(association.name)
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
next if BLACKLIST.include?(association.name)
|
67
|
+
attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
|
68
|
+
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
has_and_belongs_to_manys.each do |association|
|
71
|
+
next if except.present? && except.include?(association.name)
|
72
|
+
next unless only.blank? || only.include?(association.name)
|
72
73
|
|
73
|
-
|
74
|
+
attributes[association.name] = instance.send(association.name).map { |obj| obj.to_s }
|
75
|
+
end
|
74
76
|
end
|
75
77
|
|
76
78
|
attributes.delete_if { |_, value| value.blank? }
|
data/lib/effective_resources.rb
CHANGED
@@ -7,6 +7,8 @@ require 'effective_resources/effective_gem'
|
|
7
7
|
module EffectiveResources
|
8
8
|
MAILER_SUBJECT_PROC = Proc.new { |action, subject, resource, opts = {}| subject }
|
9
9
|
|
10
|
+
mattr_accessor :use_jit_preloader
|
11
|
+
|
10
12
|
def self.config_keys
|
11
13
|
[
|
12
14
|
:authorization_method, :default_submits,
|
@@ -18,8 +20,7 @@ module EffectiveResources
|
|
18
20
|
|
19
21
|
# We use the newer syntax for serialize calls in rails 7.1 but it changes behaviour
|
20
22
|
def self.serialize_with_coder?
|
21
|
-
|
22
|
-
#Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7')
|
23
|
+
Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7.1')
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.authorized?(controller, action, resource)
|
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: 2.
|
4
|
+
version: 2.19.0
|
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: 2023-
|
11
|
+
date: 2023-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|