webhooker 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webhooker/config.rb +2 -1
- data/lib/webhooker/model.rb +3 -2
- data/lib/webhooker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ba86fc526281269f9afa07508d97a3cd67b5fb
|
4
|
+
data.tar.gz: 289ad1848cf4f469ea3f74534f07647838628ddb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b06edbcaa0334a657127059b420229610ac66f0e98ae095ccccddce6a447fb05e4c5529fcfce65a14aae757b60f141dd7fc6a30877bccb541a393fbadefe896
|
7
|
+
data.tar.gz: a872f9c2eaa92d53b826cedb8637b8ecf992bf182cc4e8cf4555dc42e9ab47375d3684d6788b09f69e7cedc48790521293d1942026e6d9f4fc673a2867287a68
|
data/lib/webhooker/config.rb
CHANGED
@@ -2,9 +2,10 @@ require 'active_support/configurable'
|
|
2
2
|
|
3
3
|
module Webhooker
|
4
4
|
include ActiveSupport::Configurable
|
5
|
-
config_accessor :payload_key
|
5
|
+
config_accessor :payload_key, :attributes_method
|
6
6
|
|
7
7
|
configure do |c|
|
8
8
|
c.payload_key = 'payload'
|
9
|
+
c.attributes_method = :as_json
|
9
10
|
end
|
10
11
|
end
|
data/lib/webhooker/model.rb
CHANGED
@@ -29,7 +29,7 @@ module Webhooker
|
|
29
29
|
data = {
|
30
30
|
resource: model_name.singular,
|
31
31
|
action: action.to_s,
|
32
|
-
attributes:
|
32
|
+
attributes: send(*self.class.webhook_attributes_method).as_json,
|
33
33
|
}.merge(data)
|
34
34
|
Subscriber.find_each do |subscriber|
|
35
35
|
TriggerJob.perform_later subscriber, data
|
@@ -37,7 +37,7 @@ module Webhooker
|
|
37
37
|
end
|
38
38
|
|
39
39
|
module ClassMethods
|
40
|
-
attr_accessor :webhook_attributes
|
40
|
+
attr_accessor :webhook_attributes, :webhook_attributes_method
|
41
41
|
|
42
42
|
def webhooks *args
|
43
43
|
options = args.extract_options!
|
@@ -45,6 +45,7 @@ module Webhooker
|
|
45
45
|
send :"after_#{action}", :"_trigger_webhook_on_#{action}"
|
46
46
|
end
|
47
47
|
@webhook_attributes = options[:attributes].try(:map, &:to_s)
|
48
|
+
@webhook_attributes_method = options[:attributes_method] || Webhooker.config.attributes_method
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
data/lib/webhooker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webhooker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kayhide
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|