Class: Imap::Backup::Account::BackupFolders
- Inherits:
-
Object
- Object
- Imap::Backup::Account::BackupFolders
- 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
-
#each {|folder| ... } ⇒ void
Runs the enumeration.
-
#initialize(client:, account:) ⇒ BackupFolders
constructor
A new instance of BackupFolders.
-
#map {|folder| ... } ⇒ Object
Runs a map operation over the folders.
Constructor Details
#initialize(client:, account:) ⇒ BackupFolders
14 15 16 17 |
# File 'lib/imap/backup/account/backup_folders.rb', line 14 def initialize(client:, account:) @client = client @account = account end |
Instance Method Details
#each {|folder| ... } ⇒ void
This method returns an undefined value.
Runs the enumeration
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/imap/backup/account/backup_folders.rb', line 22 def each(&block) return enum_for(:each) if !block all_names = client.list configured = case when account.folders&.any? account.folders when account.folder_blacklist [] else all_names end names = if account.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
50 51 52 53 54 |
# File 'lib/imap/backup/account/backup_folders.rb', line 50 def map(&block) each.map do |folder| block.call(folder) end end |