Sha256: f51b7f1768a2a4e3f922383c86a147d0c004cf5c55f57270f38a35d5eadcd073

Contents?: true

Size: 584 Bytes

Versions: 5

Compression:

Stored size: 584 Bytes

Contents

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

    attr_accessible :key, :value

    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

5 entries across 5 versions & 1 rubygems

Version Path
glebtv-simple_captcha-0.6.3 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.2 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.1 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.6.0 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.5.2 lib/simple_captcha/storage/active_record.rb