class ApiKeyTools::Validator

Constants

TIME_THRESHOLD

Public Class Methods

new(encoder, value) click to toggle source
# File lib/api_key_tools.rb, line 27
def initialize(encoder, value)
  @encoder = encoder
  @value = value
end

Public Instance Methods

valid?() click to toggle source
# File lib/api_key_tools.rb, line 32
def valid?
  within_time_limit? && @encoder.to_s == @value
end

Private Instance Methods

within_time_limit?() click to toggle source
# File lib/api_key_tools.rb, line 37
def within_time_limit?
  time_now_as_int = Time.now.to_i
  @encoder.time >= time_now_as_int - TIME_THRESHOLD &&
    @encoder.time <= time_now_as_int
end