active_record-comments 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/comments.rb +51 -8
- 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: a9cad33bbee4634a2c13b3d6c108da34ac7c50e2
|
4
|
+
data.tar.gz: ec4874db0062e24adccd9865022120a17f9f9c52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e68299120b751403d0dd037db7871ff60db3a523693bb248313a91f44255aeb438b651fb290b7113f5127597e9b4737215990c6c84f9dd0cb6b9a661db2ea84c
|
7
|
+
data.tar.gz: ab64379e0934eee080442aec23049c8af2b9f30c33f9ed3f50da02888ce3f00978b584f6c007b96316b158671d7b50fdcbcb631d700a69a9cd5013b0d99c1842
|
@@ -2,6 +2,56 @@ require "active_record"
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
module Comments
|
5
|
+
module ExecuteWithComments
|
6
|
+
class << self
|
7
|
+
def included(base)
|
8
|
+
base.class_eval do
|
9
|
+
# 99% case
|
10
|
+
if base.method_defined?(:execute)
|
11
|
+
alias_method :execute_without_comment, :execute
|
12
|
+
def execute(query, *args, &block)
|
13
|
+
query = ActiveRecord::Comments.with_comment_sql(query)
|
14
|
+
execute_without_comment(query, *args, &block)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# ActiveRecord 3.2 vs sqlite, maybe others ...
|
19
|
+
if base.method_defined?(:exec_query)
|
20
|
+
alias_method :exec_query_without_comment, :exec_query
|
21
|
+
def exec_query(query, *args, &block)
|
22
|
+
query = ActiveRecord::Comments.with_comment_sql(query)
|
23
|
+
exec_query_without_comment(query, *args, &block)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def install!
|
30
|
+
if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
31
|
+
install ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
32
|
+
end
|
33
|
+
|
34
|
+
if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
|
35
|
+
install ActiveRecord::ConnectionAdapters::MysqlAdapter
|
36
|
+
end
|
37
|
+
|
38
|
+
if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
39
|
+
install ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
40
|
+
end
|
41
|
+
|
42
|
+
if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
43
|
+
install ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def install(adapter)
|
50
|
+
adapter.send(:include, ::ActiveRecord::Comments::ExecuteWithComments)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
5
55
|
class << self
|
6
56
|
def comment(comment)
|
7
57
|
@comment ||= []
|
@@ -25,11 +75,4 @@ module ActiveRecord
|
|
25
75
|
end
|
26
76
|
end
|
27
77
|
|
28
|
-
|
29
|
-
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
|
30
|
-
def log_with_comment_injection(query, *args, &block)
|
31
|
-
query = ActiveRecord::Comments.with_comment_sql(query)
|
32
|
-
log_without_comment_injection(query, *args, &block)
|
33
|
-
end
|
34
|
-
alias_method_chain :log, :comment_injection
|
35
|
-
end
|
78
|
+
ActiveRecord::Comments::ExecuteWithComments.install!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|