active_spy 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/active_spy.gemspec +2 -2
- data/app/controllers/active_spy/notifications_controller.rb +41 -8
- 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: 9eddbc6ab774adc7bef8293f674e5edb6543a136
|
4
|
+
data.tar.gz: 97362082bf6dcea5a8e019a659ad3431056404d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2887a5140377f86276206b62c0750aafbf13906ddfe1657c3a51dd6dc19a9b65d7895a015cc8536171b14bb92cbd7b8781ecd1b98fecd28bfa6d872af3b8a52
|
7
|
+
data.tar.gz: 3c5ef3b2fdc8a046adfccfe11aa3104719a8fcb0d7e333be1957eb28fa4f55a02150198288a84805d6f61e3a0040c14fb08640b14abc74fe3659c60382ea03e1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.3
|
data/active_spy.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: active_spy 1.3.
|
5
|
+
# stub: active_spy 1.3.3 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "active_spy"
|
9
|
-
s.version = "1.3.
|
9
|
+
s.version = "1.3.3"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -9,17 +9,50 @@ module ActiveSpy
|
|
9
9
|
result = nil
|
10
10
|
hooks.each do |hook|
|
11
11
|
if hook['post_class'].downcase == params['class']
|
12
|
-
|
13
|
-
result = listener.new.handle(params['event'])
|
14
|
-
if result.errors.present?
|
15
|
-
Rails.logger.warn("[EVENT][#{hook['post_class']}] Error on save #{result}: #{result.errors}")
|
16
|
-
render json: result.errors
|
17
|
-
else
|
18
|
-
render json: result
|
19
|
-
end and return
|
12
|
+
handle_result and return
|
20
13
|
end
|
21
14
|
end
|
22
15
|
render nothing: true, status: :not_found
|
23
16
|
end
|
24
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def handle_result(hook, params)
|
21
|
+
result = get_result(hook, params)
|
22
|
+
if result.is_a? Array
|
23
|
+
handle_array_result(result, params)
|
24
|
+
else
|
25
|
+
handle_model_result(result, params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
def get_result(hook, params)
|
31
|
+
listener = "#{hook['post_class']}Listener".constantize
|
32
|
+
result = listener.new.handle(params['event'])
|
33
|
+
end
|
34
|
+
|
35
|
+
def handle_model_result(result, params)
|
36
|
+
if result.errors.present?
|
37
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] Error receiving event #{params}")
|
38
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] Listener result: #{result}")
|
39
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] Result errors: #{result.errors}")
|
40
|
+
render json: result.errors
|
41
|
+
else
|
42
|
+
render nothing: true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def handle_array_result(result, params)
|
47
|
+
model_with_errors = result.select { |m| m.errors.present? }
|
48
|
+
if model_with_errors.any?
|
49
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] Error receiving event #{params}")
|
50
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] Listener result: #{result}")
|
51
|
+
model_with_errors.each do |model|
|
52
|
+
Rails.logger.warn("[EVENT][#{hook['post_class']}] #{model} errors: #{model.errors}")
|
53
|
+
end
|
54
|
+
else
|
55
|
+
render nothing: true
|
56
|
+
end
|
57
|
+
end
|
25
58
|
end
|