Class: SoaringSimpleCaptcha::SimpleCaptchaData

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/soaring_simple_captcha/simple_captcha_data.rb,
lib/soaring_simple_captcha/simple_captcha_data_mongoid.rb

Class Method Summary collapse

Class Method Details

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



25
26
27
28
29
# File 'lib/soaring_simple_captcha/simple_captcha_data.rb', line 25

def clear_old_data(time = 1.hour.ago)
  return unless Time === time
#         delete_all(["#{connection.quote_column_name(:updated_at)} < ?", time])
  where("updated_at < ?", time).each{|r|r.destroy}
end

.get_data(key) ⇒ Object



15
16
17
# File 'lib/soaring_simple_captcha/simple_captcha_data.rb', line 15

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

.remove_data(key) ⇒ Object



19
20
21
22
23
# File 'lib/soaring_simple_captcha/simple_captcha_data.rb', line 19

def remove_data(key)
#         delete_all(["#{connection.quote_column_name(:key)} = ?", key])
  find_by(key: key).destroy
  clear_old_data(1.hour.ago)
end