activerecord-cause 0.1.0 → 0.2.0
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/README.md +1 -0
- data/lib/activerecord/cause.rb +8 -18
- data/lib/activerecord/cause/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: 1b8288c22ff39da59d217de54b624a53c43bccf3
|
|
4
|
+
data.tar.gz: 5d23e21faba9e214643e7d6e971a04981cab9c78
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c05321c82bee03d4146e02cb4b17a41d4c1738c1a8e891c0dfc39b0f4cc0162e48ef49050563b1df483bef70076b5a0ba17ae7cb7249108a770630232bb853a
|
|
7
|
+
data.tar.gz: 2329207ae95a68d919a33961e67a56b1994c2bb79b494dbc16779026c8d8da0b1c8d569dc886c9c282a83ddfba3952e6ce93c2b47bcccd278af41429915a2527
|
data/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Activerecord::Cause
|
|
2
2
|
[](https://travis-ci.org/joker1007/activerecord-cause)
|
|
3
|
+
[](http://badge.fury.io/rb/activerecord-cause)
|
|
3
4
|
|
|
4
5
|
This gem logs where ActiveRecord actually loads record
|
|
5
6
|
|
data/lib/activerecord/cause.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "active_record"
|
|
2
|
+
require "active_record/log_subscriber"
|
|
2
3
|
|
|
3
4
|
require "activerecord/cause/version"
|
|
4
5
|
|
|
@@ -14,14 +15,9 @@ module ActiveRecord
|
|
|
14
15
|
false
|
|
15
16
|
end
|
|
16
17
|
|
|
17
|
-
class LogSubscriber <
|
|
18
|
+
class LogSubscriber < ActiveRecord::LogSubscriber
|
|
18
19
|
IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"]
|
|
19
20
|
|
|
20
|
-
def initialize
|
|
21
|
-
super
|
|
22
|
-
@odd = false
|
|
23
|
-
end
|
|
24
|
-
|
|
25
21
|
def sql(event)
|
|
26
22
|
return if ActiveRecord::Cause.match_paths.empty?
|
|
27
23
|
return unless logger.debug?
|
|
@@ -42,10 +38,12 @@ module ActiveRecord
|
|
|
42
38
|
sql = payload[:sql]
|
|
43
39
|
binds = nil
|
|
44
40
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
if respond_to?(:render_bind)
|
|
42
|
+
unless (payload[:binds] || []).empty?
|
|
43
|
+
binds = " " + payload[:binds].map { |col,v|
|
|
44
|
+
render_bind(col, v)
|
|
45
|
+
}.inspect
|
|
46
|
+
end
|
|
49
47
|
end
|
|
50
48
|
|
|
51
49
|
if odd?
|
|
@@ -65,14 +63,6 @@ module ActiveRecord
|
|
|
65
63
|
|
|
66
64
|
debug(output)
|
|
67
65
|
end
|
|
68
|
-
|
|
69
|
-
def odd?
|
|
70
|
-
@odd = !@odd
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def logger
|
|
74
|
-
ActiveRecord::Base.logger
|
|
75
|
-
end
|
|
76
66
|
end
|
|
77
67
|
end
|
|
78
68
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-cause
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- joker1007
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activerecord
|