aws-broker 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -12
  3. metadata +2 -3
  4. data/lib/shoryuken/subscriber.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15d27e2ba58c931cc347494c6420b762666dcc60
4
- data.tar.gz: 873896f0dd399e8e41f232cbcf23c3d757223ddb
3
+ metadata.gz: 5b938dd1e263fd48b2cc64c96655f5aff24f78b6
4
+ data.tar.gz: 52ebfad9aea471cb056d45b937df66f4935aa588
5
5
  SHA512:
6
- metadata.gz: df5fb8fcf7e36951e8d3b8737c66f2fa1672f292c699eda096e88edc7aff1e57acae9fa7c89ab9057f9e129737e81b28e2924025bde0b6e55b3c0b046235b915
7
- data.tar.gz: 7513b2f5159cf72adff7a05de25a502f7f0255ee1c17c35e143ea17b4ba45cf31061e7bb8d73cf0e25f5d8ef8cd513684b3d0c2921fc94fd50b8005f4de1dae6
6
+ metadata.gz: 06483e64b65a4d5c50b945ac002dc26923bc181e3f4ac7135738cbd17bfcd2dfa80ec11736973571898e004c8d60bd5e3052c8c2491741fc241e2759a36ea5a0
7
+ data.tar.gz: 1473da73a1c476be4fe019da90ad20be2fb31cd29787950e1b61b9d94389a4066389a68cf488abc3aa81b68dd77945f431edfcf87265668fba8dbde9dd78ccd7
data/README.md CHANGED
@@ -40,27 +40,23 @@ accompanying RSpec matcher is provided if the project is Rails. This simplifies
40
40
  the process of publishing events for ActiveRecord create, update, and destroy
41
41
  callbacks.
42
42
 
43
- ## Publishing
43
+ #### Publishing
44
44
 
45
45
  # app/models/user.rb
46
46
  class User < ActiveRecord::Base
47
47
  publish_event :create, :update, :destroy
48
48
  end
49
49
 
50
- ## Subscribing
50
+ The above is essentially shorthand for
51
51
 
52
- # app/subscribers/user_subscriber.rb
53
- class UserSubscriber < Shoryuken::Subscriber
54
- self.resource_class = 'User'
55
-
56
- def create; ... end
57
-
58
- def update; ... end
59
-
60
- def destroy; ... end
52
+ # app/models/user.rb
53
+ class User < ActiveRecord::Base
54
+ after_commit on: :create do
55
+ Broker.publish(:user, event: :create, id: id)
56
+ end
61
57
  end
62
58
 
63
- ## Testing
59
+ #### Testing
64
60
 
65
61
  # spec/rails_helper.rb
66
62
  require 'aws/broker/matchers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eng @ Thanx
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-20 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-sns
@@ -54,7 +54,6 @@ files:
54
54
  - lib/aws/broker/publishing.rb
55
55
  - lib/aws/broker/railtie.rb
56
56
  - lib/aws/broker/subscriber.rb
57
- - lib/shoryuken/subscriber.rb
58
57
  homepage: https://github.com/thanx/aws-broker
59
58
  licenses:
60
59
  - MIT
@@ -1,43 +0,0 @@
1
- module Shoryuken
2
- class Subscriber
3
- include Shoryuken::Worker
4
-
5
- class << self
6
- attr_reader :resource_class
7
-
8
- def queue=(queue)
9
- shoryuken_options(
10
- queue: queue,
11
- auto_delete: true,
12
- body_parser: :json
13
- )
14
- end
15
-
16
- def resource_class=(klass)
17
- @resource_class = klass
18
- end
19
- end
20
-
21
- def perform(_, body)
22
- @body = body
23
- send(event)
24
- end
25
-
26
- private
27
-
28
- def resource
29
- @resource ||= self.class.resource_class.constantize.find(message[:id])
30
- end
31
-
32
- def event
33
- message[:event]
34
- end
35
-
36
- def message
37
- @message ||= JSON.parse(@body['Message']).symbolize_keys
38
- rescue JSON::ParserError
39
- {}
40
- end
41
-
42
- end
43
- end