Class: Rsvp::AccessAttempt

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/rsvp/access_attempt.rb

Constant Summary collapse

ALLOWED_ATTEMPTS =
7
LOCK_DURATION =
15

Instance Method Summary collapse

Instance Method Details

#allowed_attemptsObject



25
26
27
# File 'app/models/rsvp/access_attempt.rb', line 25

def allowed_attempts
  ALLOWED_ATTEMPTS * multiplier
end

#locked?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
# File 'app/models/rsvp/access_attempt.rb', line 17

def locked?
  unless locked_until.nil?
    return locked_until >= Time.now
  else
    return false
  end
end

#record_attemptObject



8
9
10
11
12
13
14
15
# File 'app/models/rsvp/access_attempt.rb', line 8

def record_attempt
  self.failed_attempts += 1
  if failed_attempts >= allowed_attempts
    self.locked_until = Time.now + lock_duration
    self.locks_incurred += 1
  end
  self.save
end