Class: SimpleCaptchaData

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/simple_captcha_data.rb

Overview

Copyright © 2008 [Sur expressica.com]

Class Method Summary collapse

Class Method Details

.clear_old_data(time = 1.hour.ago) ⇒ Object



17
18
19
20
# File 'app/models/simple_captcha_data.rb', line 17

def clear_old_data(time = 1.hour.ago)
  return unless Time === time
  destroy_all("updated_at < '#{time.to_s(:db)}'")
end

.get_data(key) ⇒ Object



7
8
9
# File 'app/models/simple_captcha_data.rb', line 7

def get_data(key)
  find_by_key(key) || new(:key => key)
end

.remove_data(key) ⇒ Object



11
12
13
14
15
# File 'app/models/simple_captcha_data.rb', line 11

def remove_data(key)
  clear_old_data
  data = find_by_key(key)
  data.destroy if data
end