Class: Console1984::CommandValidator::SuspiciousTermsValidation

Inherits:
Object
  • Object
show all
Includes:
Freezeable
Defined in:
lib/console1984/command_validator/suspicious_terms_validation.rb

Overview

Validates that the command doesn’t include a term based on a configured list.

Instance Method Summary collapse

Methods included from Freezeable

freeze_all, included

Constructor Details

#initialize(suspicious_terms) ⇒ SuspiciousTermsValidation

Returns a new instance of SuspiciousTermsValidation.



5
6
7
# File 'lib/console1984/command_validator/suspicious_terms_validation.rb', line 5

def initialize(suspicious_terms)
  @suspicious_terms = suspicious_terms
end

Instance Method Details

#validate(parsed_command) ⇒ Object

Raises a Console1984::Errors::SuspiciousCommand if the term is referenced.



10
11
12
13
14
# File 'lib/console1984/command_validator/suspicious_terms_validation.rb', line 10

def validate(parsed_command)
  if contains_suspicious_term?(parsed_command)
    raise Console1984::Errors::SuspiciousCommandAttempted
  end
end