Class: Imap::Backup::Account::BackupFolders

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/imap/backup/account/backup_folders.rb

Overview

Enumerates over the account folders that are to be backed up

Instance Method Summary collapse

Constructor Details

#initialize(client:, account:) ⇒ BackupFolders

Returns a new instance of BackupFolders.



12
13
14
15
# File 'lib/imap/backup/account/backup_folders.rb', line 12

def initialize(client:, account:)
  @client = client
  @account = 
end

Instance Method Details

#each {|folder| ... } ⇒ void

This method returns an undefined value.

Runs the enumeration

Yield Parameters:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/imap/backup/account/backup_folders.rb', line 20

def each(&block)
  return enum_for(:each) if !block

  all_names = client.list

  configured =
    case
    when .folders&.any?
      .folders
    when .folder_blacklist
      []
    else
      all_names
    end

  names =
    if .folder_blacklist
      all_names - configured
    else
      all_names & configured
    end

  names.each { |name| block.call(Account::Folder.new(client, name)) }
end

#map {|folder| ... } ⇒ Object

Runs a map operation over the folders

Yield Parameters:

Returns:

  • The results of the map operation



48
49
50
51
52
# File 'lib/imap/backup/account/backup_folders.rb', line 48

def map(&block)
  each.map do |folder|
    block.call(folder)
  end
end