Class: WitchDoctor::VirusScan

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/witch_doctor/virus_scan.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/models/witch_doctor/virus_scan.rb', line 11

def as_json(options={})
  attributes
    .slice('id', 'scan_result')
    .tap { |hash|
      hash.merge!('file_url'   => file_url,
                  'scanned_at' => scanned_at.try(:utc).try(:iso8601))
    }
end

#file_urlObject

S3 will give url, file wil show mount point, we care just about s3



21
22
23
# File 'app/models/witch_doctor/virus_scan.rb', line 21

def file_url
  resource.send(mount_point).url
end

#scan_updated?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/witch_doctor/virus_scan.rb', line 29

def scan_updated?
  scan_result.in? WitchDoctor::Antivirus::RESULTS
end

#set_scanned_atObject



25
26
27
# File 'app/models/witch_doctor/virus_scan.rb', line 25

def set_scanned_at
  self.scanned_at = WitchDoctor.time_stamper.call
end