Class: AntiVirusScanner

Inherits:
Object
  • Object
show all
Includes:
Morphine
Defined in:
app/services/anti_virus_scanner.rb

Overview

This is a simple wrapper for an underlying scanner; Without it, we’ll always going to be running actual anti-virus

Defined Under Namespace

Classes: VirusDetected

Constant Summary collapse

NO_VIRUS_FOUND_RETURN_VALUE =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object_with_pid) ⇒ AntiVirusScanner

Returns a new instance of AntiVirusScanner.



12
13
14
# File 'app/services/anti_virus_scanner.rb', line 12

def initialize(object_with_pid)
  @object = object_with_pid
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



11
12
13
# File 'app/services/anti_virus_scanner.rb', line 11

def object
  @object
end

Instance Method Details

#call(file_path) ⇒ Object



16
17
18
19
20
21
22
# File 'app/services/anti_virus_scanner.rb', line 16

def call(file_path)
  if scanner_instance.call(file_path) == NO_VIRUS_FOUND_RETURN_VALUE
    return true
  else
    raise VirusDetected.new(object.pid, file_path)
  end
end