Class: Rsvp::AccessAttempt
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rsvp::AccessAttempt
- 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_attempts ⇒ Object
25 26 27 |
# File 'app/models/rsvp/access_attempt.rb', line 25 def allowed_attempts ALLOWED_ATTEMPTS * multiplier end |
#locked? ⇒ 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_attempt ⇒ Object
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 |