reactor 0.2.2 → 0.2.3
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/reactor/models/subscriber.rb +10 -11
- data/lib/reactor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec267ebefbd43e34f7b93b50689cc70c070e278a
|
4
|
+
data.tar.gz: bd94ab45a0707679751166ae566033d747c7f98d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb5493a2379d6175ada275c46b87107563981c41b5c09293b37be09b3c52f92f4189ab4b4ee16a0d239553079e124aaa2624de85e9e75b0ba6b2d372dc4e81f5
|
7
|
+
data.tar.gz: 45f765948db78ff83cd1e5d891fc4f0768c40950481c4740a38837cfbcffb4e1e02e6833507e6f1b5c2f8d82329ef8cef3605f313f991e9365bce20fd3ce056f
|
@@ -12,10 +12,6 @@ class Reactor::Subscriber < ActiveRecord::Base
|
|
12
12
|
self
|
13
13
|
end
|
14
14
|
|
15
|
-
def delay_amount
|
16
|
-
self.class.delay_amount
|
17
|
-
end
|
18
|
-
|
19
15
|
class << self
|
20
16
|
def on_fire(&block)
|
21
17
|
if block
|
@@ -28,15 +24,18 @@ class Reactor::Subscriber < ActiveRecord::Base
|
|
28
24
|
Reactor::Subscriber.find(subscriber_id).fire data
|
29
25
|
end
|
30
26
|
|
31
|
-
def subscribes_to(name = nil,
|
32
|
-
@delay_amount = delay
|
27
|
+
def subscribes_to(name = nil, data = {})
|
33
28
|
#subscribers << name
|
34
29
|
#TODO: REMEMBER SUBSCRIBERS so we can define them in code as well as with a row in the DB
|
30
|
+
# until then, here's a helper to make it easy to create with random data in postgres
|
31
|
+
# total crap I know but whatever
|
32
|
+
define_singleton_method :first_or_create! do
|
33
|
+
chain = where(event: name)
|
34
|
+
data.each do |key, value|
|
35
|
+
chain = chain.where("data @> '#{key}=#{value}'")
|
36
|
+
end
|
37
|
+
chain.first_or_create!(data)
|
38
|
+
end
|
35
39
|
end
|
36
|
-
|
37
|
-
def delay_amount
|
38
|
-
@delay_amount
|
39
|
-
end
|
40
|
-
|
41
40
|
end
|
42
41
|
end
|
data/lib/reactor/version.rb
CHANGED