magicbus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/magicbus.rb +5 -7
  2. data/lib/magicbus/version.rb +1 -1
  3. metadata +18 -2
data/lib/magicbus.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module MagicBus
2
+
3
+ require 'amqp'
2
4
 
3
5
  def self.connect(params = { host: '127.0.0.1' })
4
6
  EM.next_tick do
5
- Publisher.publisher = AMQP.connect(*params)
6
7
  Subscriber.connection = AMQP.connect(*params)
7
8
  end
8
9
  end
@@ -10,7 +11,7 @@ module MagicBus
10
11
  class Publisher
11
12
 
12
13
  class << self
13
- attr_accessor :publisher
14
+ attr_accessor :conection
14
15
  end
15
16
 
16
17
  def self.scatter(group, action, model, &block)
@@ -32,10 +33,7 @@ module MagicBus
32
33
 
33
34
  def self.send_to(user_id, action, model, data)
34
35
 
35
- warn 'Sending message to client'
36
-
37
- data = { action: action,
38
- model: model, data: data }
36
+ data = { action: action, model: model, data: data }
39
37
 
40
38
  self.publish(user_id, data)
41
39
 
@@ -44,7 +42,7 @@ module MagicBus
44
42
  private
45
43
 
46
44
  def self.publish(user_id, data)
47
- channel = Subscriber.channels[user_id]
45
+ channel = MagicBus::Subscriber.channels[user_id]
48
46
  exchange = channel.default_exchange
49
47
  exchange.publish(data.to_json, routing_key: user_id)
50
48
  end
@@ -1,5 +1,5 @@
1
1
  module MagicBus
2
2
 
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magicbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,23 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2013-06-22 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: amqp
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: ! ' A thin wrapper around RabbitMQ designed for delivery of push notifications
15
31
  to web clients. '
16
32
  email: