celluloid-io-pg-listener 0.2.1 → 0.2.2

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: 20bb2e2002bda41c462c15c5ab299defb1b63758
4
- data.tar.gz: 30afe775d53c72343dcc331dec3059b0592fb6be
3
+ metadata.gz: e6a79efd0a0cd022732811b9367802aea69dddf9
4
+ data.tar.gz: c9a7c4ad7444168edffcc1b6ea49c76268ed32b2
5
5
  SHA512:
6
- metadata.gz: c83597eb06762c5a0f0b56a4e0565cb6892e82a8f73723972c7994b59c7164057106434b12a0d4cbf4257c831701c339ec739a92fe7dd37411718b686d665055
7
- data.tar.gz: cf1fd392c57d3d48de25797a3b22e4fe0e9e2645a0261484f97d319758980db100908c6c2d86f0330a86200346a30c20572b3b5dd279945826e71e6c3fe97709
6
+ metadata.gz: 0e19ab96333005f80c89aab088fda6ebd361e5d8b8c66636bf33a22e48e8c21f25d684b8f442273c52b631134ea3dfc02fad7472592ef503cace0dbba1f04ed9
7
+ data.tar.gz: 217fac620e3848f6ff4e74f13e06c2bd9d439e97b8a7095b4aa42eebc6adae7914053d269f3950618826bea06682196c20a215dafbb9ea534a6f07323e953ed6
@@ -13,6 +13,18 @@ module CelluloidIOPGListener
13
13
  base.prepend CelluloidIOPGListener::Initialization::ArgumentExtraction
14
14
  end
15
15
 
16
+ # Defining initialize in a class including this module is optional,
17
+ # unless you have custom args you need to handle
18
+ # aside from those used by the CelluloidIOPGListener::Client
19
+ # But if you do define it, use a splat,
20
+ # hash or array splat should work,
21
+ # depending on your signature needs.
22
+ # With either splat, only pass the splat params to super,
23
+ # and handle all your custom params locally.
24
+ #
25
+ def initialize(*args)
26
+ end
27
+
16
28
  def unlisten_wrapper(channel, payload, &block)
17
29
  if block_given?
18
30
  debug "Acting on payload: #{payload} on #{channel}"
@@ -4,6 +4,7 @@ module CelluloidIOPGListener
4
4
 
5
5
  include CelluloidIOPGListener::Client
6
6
 
7
+ attr_reader :optional_arg
7
8
  # Defining initialize is optional,
8
9
  # unless you have custom args you need to handle
9
10
  # aside from those used by the CelluloidIOPGListener::Client
@@ -11,12 +12,11 @@ module CelluloidIOPGListener
11
12
  # hash or array splat should work,
12
13
  # depending on your signature needs.
13
14
  # With either splat, only pass the splat params to super,
14
- # and handle all other params locally.
15
+ # and handle all your custom params locally.
15
16
  #
16
- # def initialize(optional_arg = nil, *options)
17
- # @optional_arg = optional_arg # handle it here, don't pass it on!
18
- # super(*options)
19
- # end
17
+ def initialize(optional_arg = nil, *options)
18
+ @optional_arg = optional_arg # handle it here, don't pass it on!
19
+ end
20
20
 
21
21
  def insert_callback(channel, payload)
22
22
  # <-- within the unlisten_wrapper's block if :insert_callback is the callback_method
@@ -9,11 +9,11 @@ module CelluloidIOPGListener
9
9
  def initialize(*args)
10
10
  hash_arg = args.last.is_a?(Hash) ? args.pop : {}
11
11
  warn "[#{self.class}] You have not specified a callback_method, so :unlisten_wrapper will be used." unless hash_arg[:callback_method]
12
- @callback_method = hash_arg.delete(:callback_method) || :unlisten_wrapper
12
+ @callback_method = hash_arg[:callback_method] = hash_arg[:callback_method] || :unlisten_wrapper
13
13
  # Doesn't appear to be any other way to make it work with subclassing,
14
14
  # due to the way Celluloid Proxies the class, and hijacks the inheritance chains
15
- subclassed_client = hash_arg.delete(:subclassed_client) || false
16
- args << hash_arg unless hash_arg.empty?
15
+ subclassed_client = hash_arg[:subclassed_client] = hash_arg[:subclassed_client] || false
16
+ args << hash_arg
17
17
 
18
18
  enhance_callback_method unless @callback_method == :unlisten_wrapper
19
19
 
@@ -25,14 +25,14 @@ module CelluloidIOPGListener
25
25
  def initialize(*args)
26
26
  hash_arg = args.last.is_a?(Hash) ? args.pop : {}
27
27
  # Extract the channel first, as it is required
28
- @channel = hash_arg.delete(:channel) || raise(ArgumentError, "[#{self.class}] :channel is required, but got #{args} and #{hash_arg}")
28
+ @channel = hash_arg[:channel] || raise(ArgumentError, "[#{self.class}] :channel is required, but got #{args} and #{hash_arg}")
29
29
  # Extract the args for PG.connect
30
30
  @conninfo_hash = (hash_arg.keys & KEYS).
31
- each_with_object({}) { |k,h| h.update(k => hash_arg.delete(k)) }.
31
+ each_with_object({}) { |k,h| h.update(k => hash_arg[k]) }.
32
32
  # Future proof. Provide a way to send in any PG.connect() options not explicitly defined in KEYS
33
- merge(hash_arg.delete(:conninfo_hash) || {})
33
+ merge(hash_arg[:conninfo_hash] || {})
34
34
  # Add any other named parameters back to the args for super
35
- args << hash_arg unless hash_arg.empty?
35
+ args << hash_arg
36
36
  @super_signature = args
37
37
  end
38
38
 
@@ -1,3 +1,3 @@
1
1
  module CelluloidIOPGListener
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-io-pg-listener
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling