Class: Cloudpress::Dropbox::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudpress/dropbox/cleaner.rb

Instance Method Summary collapse

Constructor Details

#initialize(remote_paths, local_paths) ⇒ Cleaner

Returns a new instance of Cleaner.



5
6
7
8
# File 'lib/cloudpress/dropbox/cleaner.rb', line 5

def initialize(remote_paths, local_paths)
  @local_paths = local_paths
  @remote_paths = remote_paths
end

Instance Method Details

#clean!Object



14
15
16
# File 'lib/cloudpress/dropbox/cleaner.rb', line 14

def clean!
  Post.where(file_path: orphaned_paths).destroy_all if orphaned_paths.any?
end

#orphaned_pathsObject



10
11
12
# File 'lib/cloudpress/dropbox/cleaner.rb', line 10

def orphaned_paths
  @orphaned_paths ||= @local_paths - @remote_paths
end