zaikio-webhooks 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zaikio/webhooks/version.rb +1 -1
- data/lib/zaikio/webhooks.rb +23 -8
- 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: b0ee2ef247126427165c340256d3cfba655163fb972af0ca7432325b458dc66c
|
4
|
+
data.tar.gz: c46971db7afb01ad0737eb944b8c3436fe1a06428663a0ffb5443fc270743582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aba2a560667865fbc588bc096fa042db1a5f7436ff962d34f63ece00ca7ac98798346f390b0fc03ea5f7f59cfc9fb8fc741807d6ef0f6fe9a9549bc7874b415
|
7
|
+
data.tar.gz: b970e85c1793d09f67e6fa6b691aae310e1d6f17f9fc8c5c14903321d22d8e2484ec22ab9d321d123814f638cfbfb57596ab821f8c0e5e80e541ddf29d94d95a
|
data/lib/zaikio/webhooks.rb
CHANGED
@@ -6,10 +6,23 @@ module Zaikio
|
|
6
6
|
module Webhooks
|
7
7
|
class << self
|
8
8
|
attr_accessor :configuration
|
9
|
+
attr_reader :webhooks
|
9
10
|
|
10
11
|
def configure
|
11
12
|
self.configuration ||= Configuration.new
|
12
13
|
yield(configuration)
|
14
|
+
@after_configuration_callbacks ||= []
|
15
|
+
(@after_configuration_callbacks || []).each(&:call)
|
16
|
+
@after_configuration_callbacks = []
|
17
|
+
end
|
18
|
+
|
19
|
+
def after_configuration(&block)
|
20
|
+
if configuration
|
21
|
+
yield
|
22
|
+
else
|
23
|
+
@after_configuration_callbacks ||= []
|
24
|
+
@after_configuration_callbacks << block
|
25
|
+
end
|
13
26
|
end
|
14
27
|
|
15
28
|
def reset
|
@@ -23,14 +36,16 @@ module Zaikio
|
|
23
36
|
def on(event_name, job_klass, client_name: nil, perform_now: false)
|
24
37
|
@webhooks ||= {}
|
25
38
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
after_configuration do
|
40
|
+
client_names = Array(client_name || configuration.all_client_names).map(&:to_s)
|
41
|
+
client_names.each do |name|
|
42
|
+
@webhooks[name] ||= {}
|
43
|
+
@webhooks[name][event_name.to_s] ||= []
|
44
|
+
@webhooks[name][event_name.to_s] << {
|
45
|
+
perform_now: perform_now,
|
46
|
+
job_klass: job_klass
|
47
|
+
}
|
48
|
+
end
|
34
49
|
end
|
35
50
|
end
|
36
51
|
end
|