action_push 0.1.1 → 0.1.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
  SHA256:
3
- metadata.gz: b31b9ecad88a349f333d59b9a8ce4c8c17ee5e84a2cfca38cafb4db87057e151
4
- data.tar.gz: 892994f8d74f499d14ebdc51300c17c1ab0036c172527370e89c2138dafc4ced
3
+ metadata.gz: d92d74d36896cc9c7f74b94c5c6de2df3affe13c5d22c05b8439c63b9fcb1286
4
+ data.tar.gz: 454649b78977af6a74772417b904c4d3d9234ece970a36bff066fc02f470a608
5
5
  SHA512:
6
- metadata.gz: 239211cc4c0b079bd7ebda4ce2f4b337ed96456bb5057a3b2d36e913649a8cf8834320a0e0c499943d05923cf8386785049a02ec401efc878934b37e645821a2
7
- data.tar.gz: 925eb4527da4c222f7e483fc182816632846fc6bb1e017c9d113115021bcdde4ec259d15813438111f783893230dff3ba9bfbb0c38d5c56ae6817c7341e96a59
6
+ metadata.gz: 90fd9e4f83a266bf188af0cacc9791a863f4fcb1caa3797b730f8bb8c21adc504c72b590ed6a3c0022ce9c58c6c7588cea0253d261d67be6d79a3ec5b9f3d843
7
+ data.tar.gz: 6ef327d2057f1138628966fdafec6605b6aee17a9e5ac67fb323bccdccff948a88d2ba2a984a930129645db30e4eed4bd966e0921b4b9299ec80bf79e6d8c21a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- action_push (0.1.1)
4
+ action_push (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,6 +13,7 @@ module ActionPush
13
13
  autoload :ClassMethodDelivery, 'action_push/concerns/class_method_delivery'
14
14
  autoload :RegisterDefault, 'action_push/concerns/register_default'
15
15
  autoload :RegisterDeliveryMethod, 'action_push/concerns/register_delivery_method'
16
+ autoload :RegisterInterceptor, 'action_push/concerns/register_interceptor'
16
17
  end
17
18
 
18
19
  module Delivery
@@ -5,6 +5,7 @@ module ActionPush
5
5
  extend Concerns::ClassMethodDelivery
6
6
  extend Concerns::RegisterDefault
7
7
  extend Concerns::RegisterDeliveryMethod
8
+ extend Concerns::RegisterInterceptor
8
9
 
9
10
  register_default :ios, Ios::Message.new
10
11
 
@@ -13,8 +14,10 @@ module ActionPush
13
14
  def self.inherited(subclass)
14
15
  super
15
16
 
17
+ subclass.register_interceptor(interceptor)
18
+
16
19
  defaults.each do |name, placeholder|
17
- subclass.register_default name, placeholder.clone
20
+ subclass.register_default(name, placeholder.clone)
18
21
  end
19
22
 
20
23
  delivery_methods.each do |name, handler|
@@ -20,7 +20,12 @@ module ActionPush
20
20
 
21
21
  instance = new(action_name: method)
22
22
  instance.public_send(method, *argv, &block)
23
- instance.envelope.deliver
23
+ instance.envelope.pushes.each do |provider, push|
24
+ interceptor.call(instance, provider, push) do
25
+ push.deliver
26
+ end
27
+ end
28
+
24
29
  instance.envelope
25
30
  end
26
31
 
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionPush
4
+ module Concerns
5
+ module RegisterInterceptor
6
+ DEFAULT_INTERCEPTOR = ->(_instance, _provider, _push, &block) do
7
+ block.call
8
+ end
9
+
10
+ def interceptor
11
+ @interceptor || DEFAULT_INTERCEPTOR
12
+ end
13
+
14
+ def register_interceptor(handler)
15
+ @interceptor = handler
16
+ end
17
+ end
18
+ end
19
+ end
@@ -35,13 +35,5 @@ module ActionPush
35
35
  def pushes
36
36
  @pushes ||= {}
37
37
  end
38
-
39
- def deliver
40
- pushes.each do |_name, push|
41
- push.deliver if push.scheduled
42
- end
43
-
44
- nil
45
- end
46
38
  end
47
39
  end
@@ -57,7 +57,7 @@ module ActionPush
57
57
  end
58
58
 
59
59
  def deliver
60
- delivery_method.call(self)
60
+ delivery_method.call(self) if scheduled
61
61
  end
62
62
  end
63
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionPush
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_push
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aliaksandr Shylau
@@ -154,6 +154,7 @@ files:
154
154
  - lib/action_push/concerns/class_method_delivery.rb
155
155
  - lib/action_push/concerns/register_default.rb
156
156
  - lib/action_push/concerns/register_delivery_method.rb
157
+ - lib/action_push/concerns/register_interceptor.rb
157
158
  - lib/action_push/delivery/explosion.rb
158
159
  - lib/action_push/delivery/gorush.rb
159
160
  - lib/action_push/delivery/memory.rb