invisible_record 0.1.0 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/invisible_record/helper.rb +5 -3
- data/lib/invisible_record/model.rb +7 -3
- data/lib/invisible_record/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: 9f5db2bde56e730c9c64aa275b9b030ebcb00f9f1e583afe6ef1e9317103b2b1
|
4
|
+
data.tar.gz: 694f735be7c384ca3504288beebe01b6aecf08678cc72594ec69a480e6ce927e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f78f41b74c6069e6f8a458fe5480ba62a4d76d223d4ae94223fe1e6c1b668b0be29c63152343dbedffbb06c9ee46f0dd4c7559cebf720bd26727af18083a57
|
7
|
+
data.tar.gz: d591bda2f62e19cc39d42d828c0d7ea2fa6d4905502f32f46aadf8d92d8b80a3d647a994dad6cf88a4458e0cbd42d5dd8bc06af13a37a4f1bdc4d734d7107130
|
data/Gemfile.lock
CHANGED
@@ -15,14 +15,16 @@ module InvisibleRecord
|
|
15
15
|
end
|
16
16
|
|
17
17
|
klass.define_method "soft_delete" do |*args|
|
18
|
-
options = args.last
|
18
|
+
options = args.last || {}
|
19
19
|
options[:datetime] ||= DateTime.now
|
20
20
|
assign_timestamp = "#{deleted_ts_attr}="
|
21
21
|
send(assign_timestamp, options[:datetime])
|
22
22
|
end
|
23
23
|
|
24
|
-
klass.define_method "soft_delete!" do |*
|
25
|
-
|
24
|
+
klass.define_method "soft_delete!" do |*args|
|
25
|
+
options = args.last || {}
|
26
|
+
options[:datetime] ||= DateTime.now
|
27
|
+
soft_delete(datetime: options[:datetime])
|
26
28
|
save!
|
27
29
|
end
|
28
30
|
end
|
@@ -7,7 +7,7 @@ module InvisibleRecord
|
|
7
7
|
module Model
|
8
8
|
def acts_as_invisible(**options)
|
9
9
|
options.deep_symbolize_keys!
|
10
|
-
|
10
|
+
@_deleted_timestamp_attr = options[:deleted_timestamp_attribute] || "deleted_at"
|
11
11
|
raise "Only call acts_as_invisible once per model" if respond_to?(:invisible_record_model?)
|
12
12
|
|
13
13
|
class_eval do
|
@@ -15,11 +15,15 @@ module InvisibleRecord
|
|
15
15
|
def invisible_record_model?
|
16
16
|
true
|
17
17
|
end
|
18
|
+
|
19
|
+
def without_deleted
|
20
|
+
where(@_deleted_timestamp_attr => nil)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
|
20
|
-
Helper.define_hidden_attributes self, deleted_ts_attr:
|
24
|
+
Helper.define_hidden_attributes self, deleted_ts_attr: @_deleted_timestamp_attr
|
21
25
|
|
22
|
-
Helper.define_actions self, deleted_ts_attr:
|
26
|
+
Helper.define_actions self, deleted_ts_attr: @_deleted_timestamp_attr
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisible_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Rejón
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|