cache_money_millionaire 0.0.2 → 0.0.3

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.
@@ -3,6 +3,8 @@ module ActiveRecord
3
3
 
4
4
  # Include the CacheMoneyMillionaire module
5
5
  extend CacheMoneyMillionaire
6
+
7
+ attr_accessor :cache
6
8
 
7
9
 
8
10
  # Extend the find method for ActiveRecord
@@ -15,15 +17,20 @@ module ActiveRecord
15
17
  # variable based on it's validity. Then we'll remove from the arguments and pass
16
18
  # the original arguments back into our hash
17
19
  options = args.extract_options!
18
- cache = options.delete(:cache) || true
20
+
21
+ if options.has_key? :cache
22
+ cache = options[:cache]
23
+ options.delete(:cache)
24
+ else
25
+ cache = true
26
+ end
27
+
19
28
  args.push(options)
20
29
 
21
30
  # If it's cacheable and cache isn't set to false, then let's CacheMoneyMillionaire this bitch!
22
31
  # We set the cache key to the object class name and id, i.e. Post 3, User 109, etc.
23
32
  if CacheMoneyMillionaire.cacheable? and cache
24
- puts "#{self} #{args[0]}"
25
33
  cache_key = Digest::MD5.hexdigest "#{self} #{args[0]}"
26
- puts cache_key.inspect
27
34
  model = Rails.cache.fetch cache_key, expires_in: CacheMoneyMillionaire.options[:expires_in] do
28
35
  super *args
29
36
  end
@@ -1,3 +1,3 @@
1
1
  module CacheMoneyMillionaire
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_money_millionaire
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-28 00:00:00.000000000 Z
12
+ date: 2014-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 1.8.25
86
+ rubygems_version: 1.8.23
87
87
  signing_key:
88
88
  specification_version: 3
89
89
  summary: Rails ActiveRecord Query Caching like a Millionaire