Sha256: d788efed27694106846cb16bc3d678a16f51cc3c7af22db68e1bb563e7a3a394
Contents?: true
Size: 631 Bytes
Versions: 7
Compression:
Stored size: 631 Bytes
Contents
module ActiveHook class Validate attr_accessor :id, :key def initialize(options = {}) options.each { |key, value| send("#{key}=", value) } end def perform validate! @key == find_key rescue false end private def find_key ActiveHook.redis.with do |conn| conn.zrangebyscore('ah:validation', @id.to_i, @id.to_i).first end end def validate! raise Errors::Validation, 'ID must be an integer.' unless @id.is_a?(Integer) raise Errors::Validation, 'Key must be a a string.' unless @key.is_a?(String) && @key.length > 6 end end end
Version data entries
7 entries across 7 versions & 1 rubygems