class ActiveHook::Validate
Attributes
id[RW]
key[RW]
Public Class Methods
new(options = {})
click to toggle source
# File lib/activehook/validate.rb, line 5 def initialize(options = {}) options.each { |key, value| send("#{key}=", value) } end
Public Instance Methods
perform()
click to toggle source
# File lib/activehook/validate.rb, line 9 def perform validate! @key == find_key rescue false end
Private Instance Methods
find_key()
click to toggle source
# File lib/activehook/validate.rb, line 18 def find_key ActiveHook.redis.with do |conn| conn.zrangebyscore('ah:validation', @id.to_i, @id.to_i).first end end
validate!()
click to toggle source
# File lib/activehook/validate.rb, line 24 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