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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3a189848d1642d5a68d1bbae816eddf3bd4d51513d28bd369a02aa1843b5b9a
4
- data.tar.gz: ab0af0abaefa639595858f4eee2356d2ba2b96434c3d493d6a1e1cdd49877bf1
3
+ metadata.gz: a63a4abae27e2b70ac922d2f3eca07c701842b9ef2482677d200236f05a05dc8
4
+ data.tar.gz: 136206e80f42d5c019f9113d46c3260d19115f7f40ef58f0064f74b57283167f
5
5
  SHA512:
6
- metadata.gz: 660470293ca5400697b468ea97a95458a46b323ba6399ce35dea43dc2f535afdf86cae6c7f341cfea69a8ca13f54cbd156bc80fcb0d9fe11ec3c97e5c1aafbc7
7
- data.tar.gz: 7e479eef9412d2195465f1cf4194f594dba7bcb5ec47179730098042cda8d151cc855fe52d09972ef9fad0e70a104ec982af49f13ea5e9e7b6d3c9f77bc35e02
6
+ metadata.gz: 2b08dd74cfa1605c8dcf8e8082612b078ff20b93f9bfbb931f41b8d58ec2795f4a6ca0ed13f837860df4b3166c2069136ab26e0b19a46fa812af2293674bb56a
7
+ data.tar.gz: a64adaf287722c737951827174f1074ad0580688540944551f406d66fb28dadf74ca7c845c57f008aea6036c355655674328c37c89cc90be36f40738753db436
@@ -58,8 +58,7 @@ module ActsAsSlugged
58
58
  end
59
59
 
60
60
  def to_param
61
- slug
61
+ slug_was || slug
62
62
  end
63
63
 
64
64
  end
65
-
@@ -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 active_texts
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 active_texts_has_ones_ids
77
- active_texts.map { |ass| ass.name.to_s.gsub(/\Arich_text_/, '').to_sym }
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
@@ -54,7 +54,7 @@ module Effective
54
54
 
55
55
  def active_text_attributes
56
56
  {}.tap do |retval|
57
- active_texts_has_ones_ids.each { |k, v| retval[k] = [:string] }
57
+ action_texts_has_ones_ids.each { |k, v| retval[k] = [:string] }
58
58
  end
59
59
  end
60
60
 
@@ -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 (instance.present? && instance.previous_changes.present?)
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
-
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.7.2'.freeze
2
+ VERSION = '1.7.3'.freeze
3
3
  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.7.2
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-01-21 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails