Skip to content

Commit

Permalink
Fixed error on 'nil' options being passed from Rails
Browse files Browse the repository at this point in the history
  • Loading branch information
SFEley committed Mar 6, 2010
1 parent f0bdef4 commit 72b8bc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/active_support/cache/mongo_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ def initialize(collection = nil, db_name = nil)
# Inserts the value into the cache collection or updates the existing value. The value must be a valid
# MongoDB type. An *:expires_in* option may be provided, as with MemCacheStore. If one is _not_
# provided, a default expiration of 1 year is used.
def write(key, value, options={})
def write(key, value, options=nil)
super
expires = Time.now + (options[:expires_in] || 1.year)
expires = Time.now + ((options && options[:expires_in]) || 1.year)
collection.update({'key' => key}, {'$set' => {'value' => value, 'expires' => expires}}, :upsert => true)
end

# Reads the value from the cache collection.
def read(key, options={})
def read(key, options=nil)
super
if doc = collection.find_one('key' => key, 'expires' => {'$gt' => Time.now})
doc['value']
end
end

# Takes the specified value out of the collection.
def delete(key, options={})
def delete(key, options=nil)
super
collection.remove({'key' => key})
end
Expand Down
4 changes: 3 additions & 1 deletion mongo_store.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Gem::Specification.new do |s|
s.name = %q{mongo_store}
s.version = "0.1.1"
s.version = "0.1.2"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Stephen Eley"]
Expand All @@ -23,7 +23,9 @@ Gem::Specification.new do |s|
"README.rdoc",
"Rakefile",
"VERSION",
"lib/active_support/cache/mongo_store.rb",
"lib/mongo_store.rb",
"mongo_store.gemspec",
"spec/mongo_store_spec.rb",
"spec/spec.opts",
"spec/spec_helper.rb"
Expand Down

0 comments on commit 72b8bc4

Please sign in to comment.