Class: SimpleCaptcha::SimpleCaptchaData
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SimpleCaptcha::SimpleCaptchaData
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/simple_captcha/storage/mongoid.rb,
lib/simple_captcha/storage/active_record.rb
Class Method Summary collapse
Class Method Details
.clear_old_data(time = 1.hour.ago) ⇒ Object
21 22 23 24 |
# File 'lib/simple_captcha/storage/mongoid.rb', line 21 def clear_old_data(time = 1.hour.ago) return unless Time === time SimpleCaptchaData.where(:updated_at.lt => time.utc).delete_all end |
.get_data(key) ⇒ Object
12 13 14 |
# File 'lib/simple_captcha/storage/mongoid.rb', line 12 def get_data(key) SimpleCaptchaData.where(:key => key).first || new(:key => key) end |
.remove_data(key) ⇒ Object
16 17 18 19 |
# File 'lib/simple_captcha/storage/mongoid.rb', line 16 def remove_data(key) SimpleCaptchaData.where(:key => key).first.delete clear_old_data(1.hour.ago) end |