timelines 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24c65a5feb6df7817fe888742b8de6d6c7f81e532ccc41d7290fbd265ff54b1e
|
4
|
+
data.tar.gz: cb783db345463c6553cbcb3a689ad50effc5b1d83afb84e7492d66fd16e6b9b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 803e6084c141d0bdae68bb4d95062c56d7e2173b15fddc9c22c804c2019317def240954d765e8e82f506e4f48ac34c10124ef0c6290a6ddc531081bd19a34cfa
|
7
|
+
data.tar.gz: 03f429339c43f0372a58e24c9db90acec09e4f828f9ba74607166edd34a427ceebcf1b2cd699e5e460cfdb58ea0ee78f028ceadfe8d405fc54c03f6e4f9bb499
|
@@ -6,12 +6,12 @@ module Timelines
|
|
6
6
|
|
7
7
|
included do
|
8
8
|
scope :draft, -> { where(started_at: nil) }
|
9
|
-
scope :active, -> {
|
10
|
-
scope :active_at, ->(date) { where(
|
9
|
+
scope :active, -> { active_at(Time.current) }
|
10
|
+
scope :active_at, ->(date) { where(started_at: [..date], ended_at: nil).or(where(started_at: [..date], ended_at: [date..])) }
|
11
11
|
scope :with_deleted, -> { unscope(where: :ended_at) }
|
12
|
-
scope :ended, -> { where
|
12
|
+
scope :ended, -> { where(ended_at: [..Time.current]) }
|
13
13
|
scope :deleted, -> { ended }
|
14
|
-
scope :not_deleted, -> { where(ended_at: nil) }
|
14
|
+
scope :not_deleted, -> { where(ended_at: nil).or(where(ended_at: [Time.current..])) }
|
15
15
|
|
16
16
|
def active?
|
17
17
|
started? && !ended?
|
@@ -32,7 +32,15 @@ module Timelines
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def end!
|
35
|
-
|
35
|
+
return self if ended_at.present? && ended_at.past?
|
36
|
+
|
37
|
+
result = ActiveRecord::Base.transaction do
|
38
|
+
run_callbacks(:destroy) do
|
39
|
+
update(ended_at: Time.current)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
result ? self : false
|
36
44
|
end
|
37
45
|
|
38
46
|
def ended?
|
@@ -44,13 +52,11 @@ module Timelines
|
|
44
52
|
end
|
45
53
|
|
46
54
|
def destroy
|
47
|
-
|
48
|
-
|
49
|
-
update(ended_at: Time.current)
|
55
|
+
end!
|
50
56
|
end
|
51
57
|
|
52
|
-
def
|
53
|
-
|
58
|
+
def destroy!
|
59
|
+
end!
|
54
60
|
end
|
55
61
|
end
|
56
62
|
end
|
@@ -4,8 +4,12 @@ module Timelines
|
|
4
4
|
module HasAuditTrail
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
|
-
|
8
|
-
::Timelines::
|
7
|
+
included do
|
8
|
+
include ::Timelines::HasEvents
|
9
|
+
|
10
|
+
def audit_trail(reverse: false)
|
11
|
+
::Timelines::AuditTrail.new(resource: self, reverse: reverse)
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
data/lib/timelines/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timelines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Gilchrist
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|