slim_scrooge 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/slim_scrooge/callsites.rb +12 -1
- data/lib/slim_scrooge/slim_scrooge.rb +1 -1
- data/lib/slim_scrooge.rb +1 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -6,6 +6,7 @@ module SlimScrooge
|
|
6
6
|
class Callsites
|
7
7
|
CallsitesMutex = Mutex.new
|
8
8
|
@@callsites = {}
|
9
|
+
ScroogeCallsiteSample = 1..16
|
9
10
|
|
10
11
|
class << self
|
11
12
|
# Whether we have encountered a callsite before
|
@@ -20,10 +21,20 @@ module SlimScrooge
|
|
20
21
|
@@callsites[callsite_key]
|
21
22
|
end
|
22
23
|
|
24
|
+
# Fallback if you can't compile extension for some reason
|
25
|
+
#
|
26
|
+
begin
|
27
|
+
callsite_hash
|
28
|
+
rescue NameError
|
29
|
+
def callsite_hash
|
30
|
+
caller[ScroogeCallsiteSample].hash
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
# Generate a key string - uses the portion of the query before the WHERE
|
24
35
|
# together with the callsite_hash generated by callsite_hash.c
|
25
36
|
#
|
26
|
-
def callsite_key(
|
37
|
+
def callsite_key(sql)
|
27
38
|
callsite_hash + sql.gsub(/\sWHERE.*/i, "").hash
|
28
39
|
end
|
29
40
|
|
@@ -12,7 +12,7 @@ module SlimScrooge
|
|
12
12
|
module ClassMethods
|
13
13
|
def find_by_sql_with_slim_scrooge(sql)
|
14
14
|
return find_by_sql_without_slim_scrooge(sql) if sql.is_a?(Array) # don't mess with user's custom query
|
15
|
-
callsite_key = SlimScrooge::Callsites.callsite_key(
|
15
|
+
callsite_key = SlimScrooge::Callsites.callsite_key(sql)
|
16
16
|
if SlimScrooge::Callsites.has_key?(callsite_key)
|
17
17
|
find_with_callsite_key(sql, callsite_key)
|
18
18
|
elsif callsite = SlimScrooge::Callsites.create(sql, callsite_key, name) # new site that is scroogeable
|
data/lib/slim_scrooge.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_scrooge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Sykes
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-26 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|