webhook_system 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +13 -0
- data/Rakefile +1 -1
- data/lib/webhook_system/base_event.rb +15 -3
- data/lib/webhook_system/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 845cc8863c319a2a78ff235cbb41256a9bdbe850
|
4
|
+
data.tar.gz: afa19be64345c961c0989c09d09fc80341200ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0285d5a6e08624c92cdddf4eceed759c55f2839c139d922c09c8d82302114b0dcfba8416dae5ea5cb965ca8bdcc971c323087397ddae26b309217c9c1fb11820
|
7
|
+
data.tar.gz: de888a90628e3987dc5f4b0416d7eef83e8afc6f1972135c6545ecd8839f4cacb570ef4f1d73900cadc3cd808a10329c6b43c0adb60bd805278942d858b0e3a6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.1.0](https://github.com/payrollhero/webhook_system/tree/v0.1.0) (2016-02-05)
|
4
|
+
[Full Changelog](https://github.com/payrollhero/webhook_system/compare/v0.0.1...v0.1.0)
|
5
|
+
|
6
|
+
- Add easy topic mass assignment and url validation [\#2](https://github.com/payrollhero/webhook_system/pull/2) ([piotrb](https://github.com/piotrb))
|
7
|
+
|
8
|
+
## [v0.0.1](https://github.com/payrollhero/webhook_system/tree/v0.0.1) (2016-02-05)
|
9
|
+
- Initial implementation of the webhook system [\#1](https://github.com/payrollhero/webhook_system/pull/1) ([piotrb](https://github.com/piotrb))
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Rakefile
CHANGED
@@ -17,21 +17,33 @@ module WebhookSystem
|
|
17
17
|
def as_json
|
18
18
|
result = { 'event' => event_name }
|
19
19
|
each_attribute do |attribute_name, attribute_method|
|
20
|
+
validate_attribute_name attribute_name
|
20
21
|
result[attribute_name.to_s] = public_send(attribute_method).as_json
|
21
22
|
end
|
22
|
-
result
|
23
|
+
result.deep_stringify_keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.key_is_reserved?(key)
|
27
|
+
key.to_s.in? %w(event)
|
23
28
|
end
|
24
29
|
|
25
30
|
private
|
26
31
|
|
27
|
-
def
|
32
|
+
def validate_attribute_name(key)
|
33
|
+
if self.class.key_is_reserved?(key)
|
34
|
+
message = "#{self.class.name} should not be defining an attribute named #{key} since its reserved"
|
35
|
+
raise ArgumentError, message
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def each_attribute(&block)
|
28
40
|
case payload_attributes
|
29
41
|
when Array
|
30
42
|
payload_attributes.each do |attribute_name|
|
31
43
|
yield(attribute_name, attribute_name)
|
32
44
|
end
|
33
45
|
when Hash
|
34
|
-
payload_attributes.each
|
46
|
+
payload_attributes.each(&block)
|
35
47
|
else
|
36
48
|
raise ArgumetError, "don't know how to deal with payload_attributes: #{payload_attributes.inspect}"
|
37
49
|
end
|