Sha256: cd6c183a7934b5c23b6a3c6f0532cff994dd75f12418e6a0c57be65692253ad8

Contents?: true

Size: 565 Bytes

Versions: 18

Compression:

Stored size: 565 Bytes

Contents

module SimpleCaptcha
  class SimpleCaptchaData
    include Mongoid::Document
    include Mongoid::Timestamps

    field :key, type: String
    field :value, type: String

    class << self
      def get_data(key)
        data = where(:key => key).first || new(:key => key)
      end
      
      def remove_data(key)
        where(:key => key).delete_all
        clear_old_data(1.hour.ago)
      end
      
      def clear_old_data(time = 1.hour.ago)
        return unless Time === time
        where(:updated_at.lte => time).delete_all
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 6 rubygems

Version Path
simple_captcha2-0.5.0 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.4.3 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.4.2 lib/simple_captcha/simple_captcha_data_mongoid.rb
yl_simple_captcha-1.1.0 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.4.0 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.3.4 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.3.3 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.3.2 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.3.1 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.2.2 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.3.0 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.2.1 lib/simple_captcha/simple_captcha_data_mongoid.rb
simple_captcha2-0.2.0 lib/simple_captcha/simple_captcha_data_mongoid.rb
pludoni-simple_captcha-0.1.6 lib/simple_captcha/simple_captcha_data_mongoid.rb
galetahub-simple_captcha-0.1.5 lib/simple_captcha/simple_captcha_data_mongoid.rb
galetahub-simple_captcha-0.1.4 lib/simple_captcha/simple_captcha_data_mongoid.rb
loyal_simple_captcha-0.0.1 lib/simple_captcha/simple_captcha_data_mongoid.rb
foco-simple_captcha-0.1.3 lib/simple_captcha/simple_captcha_data_mongoid.rb