Class: SimpleCaptcha::SimpleCaptchaData
- Inherits:
-
Sequel::Model
- Object
- Sequel::Model
- SimpleCaptcha::SimpleCaptchaData
- Includes:
- Mongoid::Document, Mongoid::Timestamps
- Defined in:
- lib/simple_captcha/simple_captcha_data.rb,
lib/simple_captcha/simple_captcha_data_sequel.rb,
lib/simple_captcha/simple_captcha_data_mongoid.rb
Class Method Summary collapse
Class Method Details
.clear_old_data(time = 1.hour.ago) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/simple_captcha/simple_captcha_data.rb', line 26 def clear_old_data(time = 1.hour.ago) return unless Time === time where(["#{connection.quote_column_name(:updated_at)} < ?", time]).delete_all rescue ActiveRecord::Deadlocked => err Rails.logger.error "#{err.class} #{err.}" end |
.get_data(key) ⇒ Object
17 18 19 |
# File 'lib/simple_captcha/simple_captcha_data.rb', line 17 def get_data(key) where(key: key).first_or_initialize end |
.remove_data(key) ⇒ Object
21 22 23 24 |
# File 'lib/simple_captcha/simple_captcha_data.rb', line 21 def remove_data(key) where(["#{connection.quote_column_name(:key)} = ?", key]).delete_all clear_old_data(1.hour.ago) end |