active_record-events 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/active_record/events/method_factory.rb +5 -1
- data/lib/active_record/events/version.rb +1 -1
- data/spec/active_record/events_spec.rb +10 -0
- 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: 18d2fc6a8788d3190b5da3dd8dc45fbf307bb55344a6072ba24db67ff9b0e6cb
|
4
|
+
data.tar.gz: 17767f7e00810c9717cc5fa4bd92d49303b22427eb5da06a3f27ea39f8a4fbf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d39a25b8c5695aa8c81b9780744f0639ab2b0bac74296486721ec1c28cad0c67f801441b78c3faa48162d60938297a33638dada9e597a84a7c8c888c94cc86b2
|
7
|
+
data.tar.gz: afb5395aba7821776ff9aa3790d0f04f625daa1a4de6495e9069cf210a4ea3023b7449bb6cce58e9eb158887a541da6f927b9ba03e61df0974b6cd473a6beacf
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
An ActiveRecord extension providing convenience methods for timestamp management.
|
4
4
|
|
5
|
+
## Screencast
|
6
|
+
|
7
|
+
<a href="https://www.youtube.com/watch?v=TIR7YDF3O-4">
|
8
|
+
<img src="https://img.youtube.com/vi/TIR7YDF3O-4/maxresdefault.jpg" title="ActiveRecord::Events - Awesome Ruby Gems" width="50%">
|
9
|
+
</a>
|
10
|
+
|
11
|
+
[Watch screencast](https://www.youtube.com/watch?v=TIR7YDF3O-4) (courtesy of [Mike Rogers](https://github.com/MikeRogers0))
|
12
|
+
|
5
13
|
## Installation
|
6
14
|
|
7
15
|
Add the following line to your application's Gemfile:
|
@@ -199,6 +207,7 @@ end
|
|
199
207
|
- [Bartosz Pieńkowski](https://github.com/pienkowb)
|
200
208
|
- [Tomasz Skupiński](https://github.com/tskupinski)
|
201
209
|
- [Oskar Janusz](https://github.com/oskaror)
|
210
|
+
- [Mike Rogers](https://github.com/MikeRogers0)
|
202
211
|
|
203
212
|
## See also
|
204
213
|
|
@@ -48,7 +48,11 @@ module ActiveRecord
|
|
48
48
|
|
49
49
|
def define_action_method(module_, naming)
|
50
50
|
module_.send(:define_method, naming.action) do
|
51
|
-
|
51
|
+
if persisted?
|
52
|
+
touch(naming.field)
|
53
|
+
else
|
54
|
+
self[naming.field] = current_time_from_proper_timezone
|
55
|
+
end
|
52
56
|
end
|
53
57
|
end
|
54
58
|
|
@@ -32,6 +32,16 @@ RSpec.describe ActiveRecord::Events do
|
|
32
32
|
expect(task.completed_at).to eq(Time.current)
|
33
33
|
end
|
34
34
|
|
35
|
+
context 'with a non-persisted object' do
|
36
|
+
it 'updates the timestamp' do
|
37
|
+
task = build(:task, completed_at: 3.days.ago)
|
38
|
+
|
39
|
+
task.complete!
|
40
|
+
|
41
|
+
expect(task.completed_at).to eq(Time.current)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
35
45
|
it 'records multiple timestamps at once' do
|
36
46
|
Task.complete_all
|
37
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Pieńkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|