Sha256: 0345cb34f3de8ac12c71ea8992a235285e081592ef2cc9d8c7788aefd2f05a36

Contents?: true

Size: 572 Bytes

Versions: 1

Compression:

Stored size: 572 Bytes

Contents

module SoaringSimpleCaptcha
  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

1 entries across 1 versions & 1 rubygems

Version Path
soaring_simple_captcha-0.1.6 lib/soaring_simple_captcha/simple_captcha_data_mongoid.rb