Sha256: b9854da5d709a7f97b051a9d96b07b01d0307c27d9748fef06a997ee3c5ddbd9

Contents?: true

Size: 606 Bytes

Versions: 7

Compression:

Stored size: 606 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

7 entries across 7 versions & 1 rubygems

Version Path
glebtv-simple_captcha-0.5.1 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.4.6 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.4.5 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.4.4 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.4.3 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.4.1 lib/simple_captcha/storage/active_record.rb
glebtv-simple_captcha-0.3.1 lib/simple_captcha/storage/active_record.rb