active_spy 1.3.9 → 1.3.10
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 +3 -3
- data/app/controllers/active_spy/notifications_controller.rb +14 -1
- data/lib/active_spy/rails/base.rb +1 -0
- 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: a03fdab2f2cc146c75d01e0a6229eecc328406d8
|
4
|
+
data.tar.gz: de5eb5be6e6962ff7b1f237fbe5765f2e7f18a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25e424aec7aa4443e8e4d9258653997e304429f08e176058de229cd6165cc2a2a399528ac3cef3e589bf9c8fabcd0e071fc0d82e3d2357c04ac2d015c1f1a686
|
7
|
+
data.tar.gz: 5b8ff9e4c66cb832619cf4ef7701d7fd06a907e841a63636eab2ebfe618a60db4810e808ef7d3614e856ec8ca86036b7e81b5f349adedb14357d504458a18848
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.10
|
data/active_spy.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
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.10 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.10"
|
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"]
|
13
13
|
s.authors = ["Douglas Camata"]
|
14
|
-
s.date = "2014-10-
|
14
|
+
s.date = "2014-10-23"
|
15
15
|
s.description = " Watch for a method call in any class and run before/after callbacks.\n You can even watch your Rails models for events (like create, update,\n destroy), send these events to a event-runner instance and it redirect these\n events to other apps that are subscrived for them. This gem also provides\n classes that you can use to process the received events too.\n"
|
16
16
|
s.email = "d.camata@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -1,3 +1,6 @@
|
|
1
|
+
class UnsupportedORM < RuntimeError
|
2
|
+
end
|
3
|
+
|
1
4
|
module ActiveSpy
|
2
5
|
# Controller to handle notifications request coming from an event-runner
|
3
6
|
# instance.
|
@@ -20,13 +23,23 @@ module ActiveSpy
|
|
20
23
|
::Rails.logger.warn("[EVENT][#{hook['post_class']}] Listener result: #{result}")
|
21
24
|
if result.is_a? Array
|
22
25
|
handle_array_result(hook, result, params)
|
23
|
-
elsif result
|
26
|
+
elsif is_a_model?(result)
|
24
27
|
handle_model_result(hook, result, params)
|
25
28
|
else
|
26
29
|
render nothing: true
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
33
|
+
def is_a_model?(something)
|
34
|
+
if defined?(ActiveRecord)
|
35
|
+
something.is_a? ActiveRecord::Base
|
36
|
+
elsif defined?(Mongoid)
|
37
|
+
something.class.included_modules.include? Mongoid::Document
|
38
|
+
else
|
39
|
+
raise UnsupportedORM
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
30
43
|
def get_result(hook, params)
|
31
44
|
listener = "#{hook['post_class']}Listener".constantize
|
32
45
|
result = listener.new.handle(params['event'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_spy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Douglas Camata
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|