delay_henka 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/delay_henka/scheduled_change.rb +8 -2
- data/lib/delay_henka/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0d90483609b5a69d7f76de25d0976eb11c69d78
|
4
|
+
data.tar.gz: '09c3b7f7f8091320a23878548af80f89ca76fcdf'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 945923c8797038814cb1c9ceb37f8d9da2a554a85060a79abfcbc5013e319868b69d134cfdeb64b0e3b57e195521bc2668135460c020b148a4b165d54f7c7c90
|
7
|
+
data.tar.gz: f1a9925b8c68c8f0a548e88514fc9deb12e32e7f3f81233ed0840efb43ea10e96423e3441e15644dce70ce5da3928bd0295403190d09052883e8da9e507cbcc5
|
@@ -19,8 +19,9 @@ module DelayHenka
|
|
19
19
|
def self.schedule(record:, changes:, by_id:)
|
20
20
|
changes.each do |attribute, new_val|
|
21
21
|
old_val = record.public_send(attribute)
|
22
|
-
|
23
|
-
|
22
|
+
cleaned_new_val = cleanup_val(new_val)
|
23
|
+
next if old_val == cleaned_new_val
|
24
|
+
create!(changeable: record, submitted_by_id: by_id, attribute_name: attribute, old_value: old_val, new_value: cleaned_new_val)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -38,6 +39,11 @@ module DelayHenka
|
|
38
39
|
|
39
40
|
private
|
40
41
|
|
42
|
+
def self.cleanup_val(val)
|
43
|
+
return val unless val.respond_to?(:strip)
|
44
|
+
val.strip == '' ? nil : val
|
45
|
+
end
|
46
|
+
|
41
47
|
def set_initial_state
|
42
48
|
self.state ||= STATES[:STAGED]
|
43
49
|
end
|
data/lib/delay_henka/version.rb
CHANGED