multiple_man 0.5.13 → 0.5.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10e7776ff5f12168fa8984908248adbfc9b5217c
4
- data.tar.gz: 13d0b1dc30ebc18767f44c0289130878711291f8
3
+ metadata.gz: 7f336d9d6a65f813a1bbe25be73d2ed94600f6a3
4
+ data.tar.gz: 0aa6701beb28ec20efb7422876dee79b8277f8a1
5
5
  SHA512:
6
- metadata.gz: c6bdb87677e72708e57454f741b437775b564e45ffc7f01d5de40843f0b8516e616007eae9ce3c8976cf3818ed3d8a750d90c6209eef36a3d209c45fc144c9af
7
- data.tar.gz: f1518798dd88109dce33f893229171fb9e6bbae538a9097497c6d60cbf3271be17bc623ec621960c50c13fc58de49a0873c520976ae8a04dd58df5d84f2f55db
6
+ metadata.gz: b83d9ca1083970a7751b41836dfb06168a2b8e0228f801e8e94c9bc95e91f4840c40b8127a24110e3b17295cf496a1279032abedc7f57c30e36b36d6b1928d33
7
+ data.tar.gz: b94651a2419c3263732b1b75241b1b31a48f494b31c19deec9e59f1e678e8ab709d4d79c93e9c88b334e49eb7e368e0f94a38fbe7f550f3ac78d51cccad45187
@@ -4,31 +4,16 @@ require 'active_support/core_ext/module'
4
4
 
5
5
  module MultipleMan
6
6
  class Connection
7
- @mutex = Mutex.new
8
-
9
- def self.connection
10
- @mutex.synchronize do
11
- # If the server has closed our connection, re-initialize
12
- @connection = nil if @connection && @connection.closed?
13
-
14
- @connection ||= begin
15
- connection = Bunny.new(MultipleMan.configuration.connection)
16
- MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
17
- connection.start
18
- connection
19
- end
20
- end
21
- end
22
7
 
23
8
  def self.connect
24
- channel = nil
25
- connection = self.connection
26
- @mutex.synchronize do
27
- channel = connection.create_channel
28
- end
9
+ connection = Bunny.new(MultipleMan.configuration.connection)
10
+ MultipleMan.logger.debug "Connecting to #{MultipleMan.configuration.connection}"
11
+ connection.start
12
+ channel = connection.create_channel
29
13
  yield new(channel) if block_given?
30
14
  ensure
31
15
  channel.close if channel && channel.open?
16
+ connection.close if connection && connection.open?
32
17
  end
33
18
 
34
19
  attr_reader :topic
@@ -23,7 +23,9 @@ module MultipleMan
23
23
  end
24
24
 
25
25
  def init_connection
26
- channel = MultipleMan::Connection.connection.create_channel(nil, MultipleMan.configuration.worker_concurrency)
26
+ connection = Bunny.new(MultipleMan.configuration.connection)
27
+ connection.start
28
+ channel = connection.create_channel(nil, MultipleMan.configuration.worker_concurrency)
27
29
  channel.prefetch(100)
28
30
  self.connection = MultipleMan::Connection.new(channel)
29
31
  end
@@ -23,6 +23,8 @@ module MultipleMan
23
23
  end
24
24
 
25
25
  def populate_field(field, value)
26
+ field = 'source_id' if field == 'id'
27
+
26
28
  setter = "#{field}="
27
29
  if record.respond_to?(setter)
28
30
  record.send(setter, value)
@@ -7,19 +7,19 @@ module MultipleMan::Subscribers
7
7
 
8
8
  attr_reader :klass
9
9
 
10
- def create
10
+ def create(payload)
11
11
  # noop
12
12
  end
13
13
 
14
- def update
14
+ def update(payload)
15
15
  # noop
16
16
  end
17
17
 
18
- def destroy
18
+ def destroy(payload)
19
19
  # noop
20
20
  end
21
21
 
22
- def seed
22
+ def seed(payload)
23
23
  # noop
24
24
  end
25
25
 
@@ -30,7 +30,16 @@ module MultipleMan::Subscribers
30
30
  end
31
31
 
32
32
  def find_conditions(id)
33
- id.kind_of?(Hash) ? id : {multiple_man_identifier: id}
33
+ id.kind_of?(Hash) ? cleanse_id(id) : {multiple_man_identifier: id}
34
+ end
35
+
36
+ def cleanse_id(hash)
37
+ if hash.keys.length > 1 && hash.keys.include?("id")
38
+ id = hash.delete("id")
39
+ hash.merge("source_id" => id)
40
+ else
41
+ hash
42
+ end
34
43
  end
35
44
 
36
45
  attr_writer :klass
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "0.5.13"
2
+ VERSION = "0.5.15"
3
3
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe MultipleMan::Connection do
4
4
 
5
- let(:mock_bunny) { double(Bunny) }
5
+ let(:mock_bunny) { double(Bunny, open?: true, close: nil) }
6
6
  let(:mock_channel) { double(Bunny::Channel, close: nil, open?: true, topic: nil) }
7
7
 
8
8
  describe "connect" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.13
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler