Module: ConcernsOnRails::Models::Lockable::ClassMethods
- Includes:
- Support::ColumnGuard
- Defined in:
- lib/concerns_on_rails/models/lockable.rb
Instance Method Summary collapse
-
#lockable_by(attempts: DEFAULT_ATTEMPTS_FIELD, locked_at: DEFAULT_LOCKED_AT_FIELD, max_attempts: DEFAULT_MAX_ATTEMPTS, unlock_in: nil, prefix: nil, suffix: nil) ⇒ Object
Configure the lockout columns and policy.
Methods included from Support::ColumnGuard
Instance Method Details
#lockable_by(attempts: DEFAULT_ATTEMPTS_FIELD, locked_at: DEFAULT_LOCKED_AT_FIELD, max_attempts: DEFAULT_MAX_ATTEMPTS, unlock_in: nil, prefix: nil, suffix: nil) ⇒ Object
Configure the lockout columns and policy. See the module docs.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/concerns_on_rails/models/lockable.rb', line 67 def lockable_by(attempts: DEFAULT_ATTEMPTS_FIELD, locked_at: DEFAULT_LOCKED_AT_FIELD, max_attempts: DEFAULT_MAX_ATTEMPTS, unlock_in: nil, prefix: nil, suffix: nil) attempts = attempts.to_sym locked_at = locked_at.to_sym validate_lockable!(attempts, locked_at, max_attempts: max_attempts, unlock_in: unlock_in) self.lockable_attempts_field = attempts self.lockable_locked_at_field = locked_at self.lockable_max_attempts = max_attempts self.lockable_unlock_in = unlock_in ensure_columns!(LABEL, attempts, locked_at) validate_lockable_attempts_column!(attempts) define_lockable_scopes(prefix, suffix) end |