Class: SimpleCaptcha::SimpleCaptchaData

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

Class Method Summary collapse

Class Method Details

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


27
28
29
30
# File 'lib/simple_captcha/simple_captcha_data.rb', line 27

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

.get_data(key) ⇒ Object


18
19
20
# File 'lib/simple_captcha/simple_captcha_data.rb', line 18

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

.rails3?Boolean

Returns:

  • (Boolean)

3
4
5
# File 'lib/simple_captcha/simple_captcha_data.rb', line 3

def self.rails3?
  ::ActiveRecord::VERSION::MAJOR == 3
end

.remove_data(key) ⇒ Object


22
23
24
25
# File 'lib/simple_captcha/simple_captcha_data.rb', line 22

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