actionpusher 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -34,10 +34,18 @@ Your push notifications can then be called like a standard Rails mailer:
34
34
  MyPusher.send_a_push_notification.deliver
35
35
  ```
36
36
 
37
+ In the event that you're using `Delayed::Job` for your background processing, you can work with it in the same way that
38
+ ActionMailer would:
39
+
40
+ ```
41
+ MyPusher.delay.send_a_push_notification
42
+ ```
43
+
37
44
  ## TODO
38
45
 
46
+ * Implement [interceptor pattern](https://github.com/rails/rails/blob/980cdd30dc06e7cdf3490062731bb9f14789daec/actionmailer/lib/action_mailer/base.rb#L463)
39
47
  * YAML based configuration for pem files
40
- * Get working with DelayedJob: `MyPusher.delay.send_a_push_notification`
48
+ * <strike>Get working with DelayedJob: `MyPusher.delay.send_a_push_notification`</strike>
41
49
 
42
50
  ## Copyright
43
51
 
@@ -1,5 +1,4 @@
1
1
  require 'action_pusher/base'
2
2
  require 'action_pusher/apn_certificate'
3
3
 
4
- module ActionPusher
5
- end
4
+ require 'action_pusher/railtie' if defined?(Rails)
@@ -0,0 +1,21 @@
1
+ module Delayed
2
+ class PerformablePusher < PerformableMethod
3
+ def perform
4
+ object.send(method_name, *args)
5
+ end
6
+ end
7
+
8
+ module DelayPush
9
+ def delay(options = {})
10
+ proxy = DelayProxy.new(PerformablePusher, self, options)
11
+
12
+ # Redefine method_missing on DelayProxy to instantiate our pusher properly
13
+ def proxy.method_missing(method, *args)
14
+ pusher = @target.send(method.to_sym, *args)
15
+ Job.enqueue({:payload_object => @payload_class.new(pusher, :deliver, nil)}.merge(@options))
16
+ end
17
+
18
+ proxy
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ require 'action_pusher'
2
+ require 'rails'
3
+
4
+ module ActionPusher
5
+ class Railtie < Rails::Railtie
6
+ config.after_initialize do
7
+ begin
8
+ require 'delayed_job'
9
+ require 'action_pusher/delayed'
10
+
11
+ ActionPusher::Base.extend(Delayed::DelayPush)
12
+ rescue
13
+ # noop
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpusher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -85,6 +85,8 @@ files:
85
85
  - README.md
86
86
  - lib/action_pusher/apn_certificate.rb
87
87
  - lib/action_pusher/base.rb
88
+ - lib/action_pusher/delayed.rb
89
+ - lib/action_pusher/railtie.rb
88
90
  - lib/action_pusher.rb
89
91
  homepage: https://github.com/PetroFeed/actionpusher
90
92
  licenses: