active_events 0.0.0 → 0.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/lib/active_events.rb +15 -12
- 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: 65399b5cabbd10a0f14e5a8706216e81724a27011f00c24ec37b0723289643f9
|
|
4
|
+
data.tar.gz: 8625a03384281bf6859a29ed1d9a6d0b847fae2f0b938e3bc184fc22423f30ff
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d5e552dc3a83be59a06203fe7d6d18bfbc7b6a9d15085a50649bb9e7840fad11b5aa05edd19fd03f1489003e8827045ac62dd7acd1bc74fcb687c8b574759fe
|
|
7
|
+
data.tar.gz: 34d5c7ca15f8ef8f13c64e8f69f67427f52332b8570af535227557ddb3bad77aba3e265c7489e0826301556175893fa85c7c46a153d93957970ed21170e35bed
|
data/lib/active_events.rb
CHANGED
|
@@ -4,16 +4,25 @@ module ActiveEvents
|
|
|
4
4
|
extend ActiveSupport::Concern
|
|
5
5
|
|
|
6
6
|
module ClassMethods
|
|
7
|
-
def watch_events
|
|
7
|
+
def watch_events(options = {})
|
|
8
8
|
# don't allow multiple calls
|
|
9
9
|
return if included_modules.include?(ActiveEvents::InstanceMethods)
|
|
10
10
|
|
|
11
|
+
class_attribute :events_options, instance_writer: false
|
|
12
|
+
|
|
13
|
+
self.events_options = options
|
|
14
|
+
normalize_events_options
|
|
15
|
+
|
|
11
16
|
extend ActiveEvents::ActiveEventsClassMethods
|
|
12
17
|
include ActiveEvents::InstanceMethods
|
|
13
18
|
|
|
14
|
-
after_create :active_event_create
|
|
15
|
-
before_update :active_event_update
|
|
16
|
-
before_destroy :active_event_destroy
|
|
19
|
+
after_create :active_event_create unless events_options[:ignore].include?(:create)
|
|
20
|
+
before_update :active_event_update unless events_options[:ignore].include?(:update)
|
|
21
|
+
before_destroy :active_event_destroy unless events_options[:ignore].include?(:destroy)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def normalize_events_options
|
|
25
|
+
events_options[:ignore] = Array.wrap(events_options[:ignore])
|
|
17
26
|
end
|
|
18
27
|
end
|
|
19
28
|
|
|
@@ -23,11 +32,9 @@ module ActiveEvents
|
|
|
23
32
|
class CreateEvent
|
|
24
33
|
include BunnyEvent
|
|
25
34
|
|
|
26
|
-
# define the event options for queueing this event. Each event type can have different options.
|
|
27
35
|
event_options exchange: '',
|
|
28
36
|
routing_key: 'create_event'
|
|
29
37
|
|
|
30
|
-
# We can define what the message payload looks like here.
|
|
31
38
|
def initialize(message)
|
|
32
39
|
@message = { message: message }.to_json
|
|
33
40
|
end
|
|
@@ -36,11 +43,9 @@ module ActiveEvents
|
|
|
36
43
|
class UpdateEvent
|
|
37
44
|
include BunnyEvent
|
|
38
45
|
|
|
39
|
-
# define the event options for queueing this event. Each event type can have different options.
|
|
40
46
|
event_options exchange: '',
|
|
41
|
-
routing_key: '
|
|
47
|
+
routing_key: 'update_event'
|
|
42
48
|
|
|
43
|
-
# We can define what the message payload looks like here.
|
|
44
49
|
def initialize(message)
|
|
45
50
|
@message = { message: message }.to_json
|
|
46
51
|
end
|
|
@@ -49,11 +54,9 @@ module ActiveEvents
|
|
|
49
54
|
class DestroyEvent
|
|
50
55
|
include BunnyEvent
|
|
51
56
|
|
|
52
|
-
# define the event options for queueing this event. Each event type can have different options.
|
|
53
57
|
event_options exchange: '',
|
|
54
|
-
routing_key: '
|
|
58
|
+
routing_key: 'destroy_event'
|
|
55
59
|
|
|
56
|
-
# We can define what the message payload looks like here.
|
|
57
60
|
def initialize(message)
|
|
58
61
|
@message = { message: message }.to_json
|
|
59
62
|
end
|