Sha256: a65466cf59cc1a89f1377a8172aafd2edbf5fe946269e8da55c8223b9bb07ebe

Contents?: true

Size: 550 Bytes

Versions: 4

Compression:

Stored size: 550 Bytes

Contents

module SimpleCaptcha
  class SimpleCaptchaData < ::ActiveRecord::Base
    self.table_name = "simple_captcha_data"

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
glebtv-simple_captcha-0.7.0 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.7 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.5 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.4 lib/simple_captcha/storage/active_record.rb