timelines 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +2 -1
- data/lib/timelines/models/concerns/tracks_events.rb +2 -2
- data/lib/timelines/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c47e84c6bedc124729951662521fc68baeaede671752dc275f7d2114bcd4983
|
4
|
+
data.tar.gz: 1875a77f55430a151878b874b99dabb4d7adfb9a3ba68a2829d861485f907b47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d698afedff13c041581a16b149d5565eee5ce537740d2c8a601b292ab14dd1337eb0807e993e669e7e50ed98eb68c04d875da317a6aff607db910cac98d2d48b
|
7
|
+
data.tar.gz: 606a6e61c05cb1972b1ca4eca2d39556954e6adc75a640d81790a526411088abe392bc38a6428c72db652ef18a09b4a4592a0ed06c81ecac1025fe28f7b2b95b
|
data/README.md
CHANGED
@@ -49,11 +49,12 @@ And the following Class methods:
|
|
49
49
|
|
50
50
|
Enables defining conditions for automated logging of events for a record's many lifecycle events, which are logged through an ActiveJob adapter.
|
51
51
|
|
52
|
-
The parameters are 4 procs that define the resource, actor, event, and conditions for logging the event. Conditions can be used to ensure an event only fires on a new record, or on a record that has been updated in a specific way/meets certain criteria to be eligible to log the event.
|
52
|
+
The parameters are an optional `on:` param (which defaults to `before_save`), and 4 procs that define the resource, actor, event, and conditions for logging the event. Conditions can be used to ensure an event only fires on a new record, or on a record that has been updated in a specific way/meets certain criteria to be eligible to log the event.
|
53
53
|
```ruby
|
54
54
|
include Timelines::TracksEvents
|
55
55
|
tracks_timelines_event :create_event,
|
56
56
|
resource: ->(instance) { instance },
|
57
|
+
on: :before_create,
|
57
58
|
actor: ->(instance) { instance.created_by },
|
58
59
|
event: ->(instance) { "instance::create" },
|
59
60
|
conditions: ->(instance) { instance.new_record? }
|
@@ -5,7 +5,7 @@ module Timelines
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
def self.tracks_timelines_event(name, actor:, resource:, event:, conditions:)
|
8
|
+
def self.tracks_timelines_event(name, actor:, resource:, event:, conditions:, on: :before_save)
|
9
9
|
method_name = "track_#{name}_event"
|
10
10
|
define_method method_name.to_sym do
|
11
11
|
event_should_be_logged = conditions.call(self)
|
@@ -19,7 +19,7 @@ module Timelines
|
|
19
19
|
::Timelines::EventLogger.perform_later(event_actor.class.name, event_actor.id, event_resource.class.name, event_resource.id, event_summary, Time.current)
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
send(on, method_name.to_sym)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/timelines/version.rb
CHANGED