reactor 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 899765d039dc16a3ae752e6bf347c96b45ed0fac
4
- data.tar.gz: 0b1aea882ae877eade8fc589c0c553e396c8443b
3
+ metadata.gz: ec267ebefbd43e34f7b93b50689cc70c070e278a
4
+ data.tar.gz: bd94ab45a0707679751166ae566033d747c7f98d
5
5
  SHA512:
6
- metadata.gz: d7f4df1a877d2141c96cda533f1313e42c7a6616cfef2a69ee839142e02d2160205cc4b0f919ecda8e0b5be309115bfc47dc6df05e709f55c870e821a6ca9cc0
7
- data.tar.gz: eccf1649e9a6fb011ae78d578336b0748008678f14a31b2e175ba24d427edffe075bb244ce16d79a33d050501e7dd88d67604eb84956fc57ff1ba27c76ed02a6
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, delay: 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
@@ -1,3 +1,3 @@
1
1
  module Reactor
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred