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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6652b994c802a947f7034b97b34028bb6affa08af96f131b5afe50825579a163
4
- data.tar.gz: 3b9477b6bb242d1e5a2fa5f5bd95629b1c971b9e1debfee827d74939dfaeab2f
3
+ metadata.gz: 9f5db2bde56e730c9c64aa275b9b030ebcb00f9f1e583afe6ef1e9317103b2b1
4
+ data.tar.gz: 694f735be7c384ca3504288beebe01b6aecf08678cc72594ec69a480e6ce927e
5
5
  SHA512:
6
- metadata.gz: 57172f40f8b01b3500b32f8d9504f001dd78cde6e0a9cc329da7e79e0c51c36d1db59ff3e796b1327005ca28f689599cc6c6b078486ff1f4328d691550da4fc5
7
- data.tar.gz: d5baf2cf0b4fe0f5c860d4483c06c657e2b0914fb31583bb999061bee4d838785ed7c0131966b0743a3198f820013f74ad9d24309af5e6e88598ede9fbd517d2
6
+ metadata.gz: 07f78f41b74c6069e6f8a458fe5480ba62a4d76d223d4ae94223fe1e6c1b668b0be29c63152343dbedffbb06c9ee46f0dd4c7559cebf720bd26727af18083a57
7
+ data.tar.gz: d591bda2f62e19cc39d42d828c0d7ea2fa6d4905502f32f46aadf8d92d8b80a3d647a994dad6cf88a4458e0cbd42d5dd8bc06af13a37a4f1bdc4d734d7107130
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invisible_record (0.1.0)
4
+ invisible_record (0.1.4)
5
5
  activemodel (>= 5)
6
6
  activerecord (>= 5)
7
7
 
@@ -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 |*_args|
25
- soft_delete
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
- deleted_timestamp_attr = options[:deleted_timestamp_attribute] || "deleted_at"
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: deleted_timestamp_attr
24
+ Helper.define_hidden_attributes self, deleted_ts_attr: @_deleted_timestamp_attr
21
25
 
22
- Helper.define_actions self, deleted_ts_attr: deleted_timestamp_attr
26
+ Helper.define_actions self, deleted_ts_attr: @_deleted_timestamp_attr
23
27
  end
24
28
  end
25
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InvisibleRecord
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.4"
5
5
  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.0
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-15 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel