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
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 = account end |
Instance Method Details
#each {|folder| ... } ⇒ void
This method returns an undefined value.
Runs the enumeration
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 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
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 |