activerecord-cause 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb40767d288b56d2b5cba6f76da6a01246fd2307
4
- data.tar.gz: 35038b8eee805737e7ad5ecdbdbe6ef7e7b82590
3
+ metadata.gz: 1b8288c22ff39da59d217de54b624a53c43bccf3
4
+ data.tar.gz: 5d23e21faba9e214643e7d6e971a04981cab9c78
5
5
  SHA512:
6
- metadata.gz: ad68f66803727c23c1dce8e8faf0c0207f51556250c9150df0d4da00e592578bf2743172df9e42d1c6343c3987ccee87a5b256e7fef540fe0e46735c6506f77e
7
- data.tar.gz: 99ac93d77d69c7140d17aac2c4e1a17d5cb7de004ab58e8da0a98ae21ed4cd0d31dbca292b7e0afbe4ab74035ecf5e0d73fd5adf190fc7f7212d561f2ec8a0c1
6
+ metadata.gz: 1c05321c82bee03d4146e02cb4b17a41d4c1738c1a8e891c0dfc39b0f4cc0162e48ef49050563b1df483bef70076b5a0ba17ae7cb7249108a770630232bb853a
7
+ data.tar.gz: 2329207ae95a68d919a33961e67a56b1994c2bb79b494dbc16779026c8d8da0b1c8d569dc886c9c282a83ddfba3952e6ce93c2b47bcccd278af41429915a2527
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Activerecord::Cause
2
2
  [![Build Status](https://travis-ci.org/joker1007/activerecord-cause.svg?branch=master)](https://travis-ci.org/joker1007/activerecord-cause)
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-cause.svg)](http://badge.fury.io/rb/activerecord-cause)
3
4
 
4
5
  This gem logs where ActiveRecord actually loads record
5
6
 
@@ -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 < ActiveSupport::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
- unless (payload[:binds] || []).empty?
46
- binds = " " + payload[:binds].map { |col,v|
47
- render_bind(col, v)
48
- }.inspect
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module Cause
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.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-15 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord