effective_resources 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/acts_as_slugged.rb +1 -2
- data/app/models/effective/resources/associations.rb +3 -3
- data/app/models/effective/resources/attributes.rb +1 -1
- data/app/models/effective/resources/instance.rb +22 -6
- data/lib/effective_resources/version.rb +1 -1
- 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: a63a4abae27e2b70ac922d2f3eca07c701842b9ef2482677d200236f05a05dc8
|
4
|
+
data.tar.gz: 136206e80f42d5c019f9113d46c3260d19115f7f40ef58f0064f74b57283167f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b08dd74cfa1605c8dcf8e8082612b078ff20b93f9bfbb931f41b8d58ec2795f4a6ca0ed13f837860df4b3166c2069136ab26e0b19a46fa812af2293674bb56a
|
7
|
+
data.tar.gz: a64adaf287722c737951827174f1074ad0580688540944551f406d66fb28dadf74ca7c845c57f008aea6036c355655674328c37c89cc90be36f40738753db436
|
@@ -69,12 +69,12 @@ module Effective
|
|
69
69
|
active_storage_has_ones.map { |ass| ass.name.to_s.gsub(/_attachment\z/, '').to_sym }
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def action_texts
|
73
73
|
klass.reflect_on_all_associations(:has_one).select { |ass| ass.class_name == 'ActionText::RichText' }
|
74
74
|
end
|
75
75
|
|
76
|
-
def
|
77
|
-
|
76
|
+
def action_texts_has_ones_ids
|
77
|
+
action_texts.map { |ass| ass.name.to_s.gsub(/\Arich_text_/, '').to_sym }
|
78
78
|
end
|
79
79
|
|
80
80
|
def nested_resources
|
@@ -49,7 +49,7 @@ module Effective
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
has_ones.each do |association|
|
52
|
+
(action_texts + has_ones).each do |association|
|
53
53
|
next if except.present? && except.include?(association.name)
|
54
54
|
next unless only.blank? || only.include?(association.name)
|
55
55
|
|
@@ -74,9 +74,22 @@ module Effective
|
|
74
74
|
attributes.delete_if { |_, value| value.blank? }
|
75
75
|
end
|
76
76
|
|
77
|
+
def instance_action_texts_previous_changes
|
78
|
+
return {} unless instance.present? && action_texts.present?
|
79
|
+
|
80
|
+
action_texts
|
81
|
+
.map { |ass| instance.send(ass.name) }
|
82
|
+
.compact
|
83
|
+
.select { |obj| obj.previous_changes['body'].present? }
|
84
|
+
.inject({}) { |h, obj| h[obj.name.to_sym] = obj.previous_changes['body']; h }
|
85
|
+
end
|
86
|
+
|
77
87
|
# used by effective_logging
|
78
88
|
def instance_changes(only: nil, except: nil)
|
79
|
-
return {} unless
|
89
|
+
return {} unless instance.present?
|
90
|
+
|
91
|
+
action_texts_changes = instance_action_texts_previous_changes()
|
92
|
+
return {} unless instance.previous_changes.present? || action_texts_changes.present?
|
80
93
|
|
81
94
|
# Build up our only and except
|
82
95
|
only = Array(only).map(&:to_sym)
|
@@ -94,6 +107,13 @@ module Effective
|
|
94
107
|
changes = changes.except(*except) if except.present?
|
95
108
|
changes = changes.slice(*only) if only.present?
|
96
109
|
|
110
|
+
action_texts_changes.each do |name, (before, after)|
|
111
|
+
next if except.present? && except.include?(name)
|
112
|
+
next unless only.blank? || only.include?(name)
|
113
|
+
|
114
|
+
changes[name] = [before.to_s, after.to_s]
|
115
|
+
end
|
116
|
+
|
97
117
|
# Log to_s changes on all belongs_to associations
|
98
118
|
belong_tos.each do |association|
|
99
119
|
next if except.present? && except.include?(association.name)
|
@@ -110,7 +130,3 @@ module Effective
|
|
110
130
|
end
|
111
131
|
end
|
112
132
|
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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.7.
|
4
|
+
version: 1.7.3
|
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-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|