effective_resources 2.18.4 → 2.18.5
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 +4 -4
- data/app/models/effective/resources/instance.rb +29 -27
- data/lib/effective_resources/version.rb +1 -1
- data/lib/effective_resources.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15aae84ff3fea90339f7efe098d2866a9d2bc88b335b9655546106a08c4d1bed
|
4
|
+
data.tar.gz: 88309bf5bd6c7d80c17e879047646ab92ab49780db7e07e1df4bba525702226d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a632db851e6c74e33f4e7ff5daccc7990df2009a6f1fd18bce165e94a88bf14b31d5272c446b4e2dc8efbc09f2efc40aea2eab46a2ac5171bde47988c037db2b
|
7
|
+
data.tar.gz: 18b551721691c45be04f467855fd8c28f333c856fb0f30b3cc06615068ef84b6e16dad213a1cafbc10cc5836ba79f90e0a2728be50e2845022bceb7e6c16a457
|
@@ -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
@@ -18,8 +18,7 @@ module EffectiveResources
|
|
18
18
|
|
19
19
|
# We use the newer syntax for serialize calls in rails 7.1 but it changes behaviour
|
20
20
|
def self.serialize_with_coder?
|
21
|
-
|
22
|
-
#Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7')
|
21
|
+
Gem::Version.new(Gem.loaded_specs['rails'].version.to_s) >= Gem::Version.new('7.1')
|
23
22
|
end
|
24
23
|
|
25
24
|
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.18.
|
4
|
+
version: 2.18.5
|
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-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|