Permalink
Browse files

SimpleCaptchaData functions modified

  • Loading branch information...
sur
sur committed Jan 19, 2008
1 parent 5c7528d commit 07a9f2502d355e289942041bb62dbb57884c623e
Showing with 6 additions and 7 deletions.
  1. +1 −1 README
  2. +5 −6 lib/simple_captcha_data.rb
View
2 README
@@ -2,7 +2,7 @@ Copyright (c) 2008 [Sur http://expressica.com]
SimpleCaptcha
=========================================================================================
- Version: 1.2.4
+ Version: edge
Author: Sur [http://expressica.com]
Plugin Homepage: http://expressica.com/simple_captcha
Contributors: http://vinsol.com/team
View
@@ -5,21 +5,20 @@ class SimpleCaptchaData < ActiveRecord::Base
class << self
def get_data(key)
- clear_old_data
- data = find_by_key(key) || new
- data.key = key if data.new_record?
- data
+ data = find_by_key(key) || new(:key => key)
end
def remove_data(key)
+ clear_old_data
data = find_by_key(key)
data.destroy if data
end
private
- def clear_old_data
- destroy_all("updated_at < '#{1.hour.ago.to_s(:db)}' ")
+ def clear_old_data(time = 1.hour.ago)
+ return unless Time === time
+ destroy_all("updated_at < '#{time.to_s(:db)}'")
end
end

0 comments on commit 07a9f25

Please sign in to comment.