CachedSupermodel 0.1.2.11 → 0.1.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/cs_active_record.rb +9 -4
- metadata +2 -2
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'hoe'
|
5
5
|
require './lib/cached_supermodel.rb'
|
6
6
|
|
7
|
-
Hoe.new('CachedSupermodel', '0.1.2.
|
7
|
+
Hoe.new('CachedSupermodel', '0.1.2.12') do |p|
|
8
8
|
p.summary = 'A library that automatically caches all ActiveRecord::Base instances in memcache using the AdoccaMemcache gem.'
|
9
9
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
10
10
|
p.author = 'adocca Entertainment AB'
|
data/lib/cs_active_record.rb
CHANGED
@@ -89,6 +89,10 @@ def self.#{finder}_get_ids(*args)
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
unless descends_from_active_record?
|
93
|
+
where << type_condition
|
94
|
+
end
|
95
|
+
|
92
96
|
query << (' WHERE ' + where.join(' AND '))
|
93
97
|
|
94
98
|
if hash_args.include?(:order)
|
@@ -156,13 +160,13 @@ def self.#{finder}_orig(*args)
|
|
156
160
|
rval = self.#{finder}_get_ids(*args)
|
157
161
|
if Array === rval
|
158
162
|
rval.collect do |oid|
|
159
|
-
self.find(oid) rescue nil
|
163
|
+
self.base_class.find(oid) rescue nil
|
160
164
|
end.compact
|
161
165
|
else
|
162
166
|
if rval.nil?
|
163
167
|
raise ActiveRecord::RecordNotFound
|
164
168
|
else
|
165
|
-
self.find(rval)
|
169
|
+
self.base_class.find(rval)
|
166
170
|
end
|
167
171
|
end
|
168
172
|
end
|
@@ -361,8 +365,9 @@ before_destroy :invalidate_cached_#{finder}
|
|
361
365
|
##
|
362
366
|
# The local cache key for this record.
|
363
367
|
# If this class is STI, store the record as the top-level class instead.
|
364
|
-
#
|
365
|
-
|
368
|
+
# * Folder.find(1) => returns a subclassed GalleryFolder, Folder.find(1) will not be cached
|
369
|
+
# This is happens quite often when objects are stored as polymorphic assocations
|
370
|
+
|
366
371
|
|
367
372
|
def self.cache_key_local(klass, id)
|
368
373
|
klass = Module.const_get(klass) unless Class === klass
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: CachedSupermodel
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.2.
|
7
|
-
date: 2008-01-
|
6
|
+
version: 0.1.2.12
|
7
|
+
date: 2008-01-23 00:00:00 +01:00
|
8
8
|
summary: A library that automatically caches all ActiveRecord::Base instances in memcache using the AdoccaMemcache gem.
|
9
9
|
require_paths:
|
10
10
|
- lib
|