Sha256: a8566e4ef9302a1f1eedbd2919d91ddbadc9788664b007f9092b63874ba6a743

Contents?: true

Size: 602 Bytes

Versions: 6

Compression:

Stored size: 602 Bytes

Contents

module SimpleCaptcha
  class SimpleCaptchaData < ::ActiveRecord::Base
    set_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

6 entries across 6 versions & 3 rubygems

Version Path
wxianfeng_simple_captcha-0.2.0 lib/simple_captcha/simple_captcha_data.rb
wxianfeng_simple_captcha-0.1.0 lib/simple_captcha/simple_captcha_data.rb
galetahub-simple_captcha-0.1.3 lib/simple_captcha/simple_captcha_data.rb
galetahub-simple_captcha-0.1.2 lib/simple_captcha/simple_captcha_data.rb
galetahub-simple_captcha-0.1.1 lib/simple_captcha/simple_captcha_data.rb
nogara-simple_captcha-0.1.1 lib/simple_captcha/simple_captcha_data.rb