Module: MailHandler::Receiving::FileHandling

Included in:
FileList, FolderChecker
Defined in:
lib/mailhandler/receiving/filelist/base.rb

Instance Method Summary collapse

Instance Method Details

#access_file(file, default_return = false, &block) ⇒ Object

if file exists, execute file operation, otherwise return default return value when it doesn’t



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mailhandler/receiving/filelist/base.rb', line 13

def access_file(file, default_return = false, &block)

  if File.exists? file

    begin

      block.call

    rescue => e

      raise e if File.exists? file
      default_return

    end

  else

    default_return

  end

end