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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0eff14a1838b467534d2d35233a9a2026958cc4f62f9cdb782f5ccbd9d7185d0
4
- data.tar.gz: 785b4ca671477ad7e6f9b339407d377fb0ab1c8f51a4ed36655dced6464c659e
3
+ metadata.gz: 7c47e84c6bedc124729951662521fc68baeaede671752dc275f7d2114bcd4983
4
+ data.tar.gz: 1875a77f55430a151878b874b99dabb4d7adfb9a3ba68a2829d861485f907b47
5
5
  SHA512:
6
- metadata.gz: a6eca22beb642e9b503235aa829c6a8f97fc399ee59c7082cd77f664ef7e38ef49d2fd5993fd30aeb8da973cde3bbeb27b510e5fa4989502a631f614ecec10bc
7
- data.tar.gz: c6022bf2a2ef87372fcc5d85ff54e3702a2a7c193b62766b2e3cb95b7d5b29f7a828b6c3458efaffe844bb63d9452eaa16d23327a1edec147a72beb5534eb02a
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
- before_save method_name.to_sym
22
+ send(on, method_name.to_sym)
23
23
  end
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Timelines
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timelines
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Gilchrist