Class: Imap::Backup::Account
- Inherits:
-
Object
- Object
- Imap::Backup::Account
- Defined in:
- lib/imap/backup/account.rb,
lib/imap/backup/account/folder.rb,
lib/imap/backup/account/connection.rb,
lib/imap/backup/account/connection/folder_names.rb,
lib/imap/backup/account/connection/backup_folders.rb
Defined Under Namespace
Classes: Connection, Folder
Constant Summary collapse
- DEFAULT_MULTI_FETCH_SIZE =
1
Instance Attribute Summary collapse
-
#changes ⇒ Object
readonly
Returns the value of attribute changes.
-
#connection_options ⇒ Object
Returns the value of attribute connection_options.
-
#folders ⇒ Object
Returns the value of attribute folders.
-
#local_path ⇒ Object
Returns the value of attribute local_path.
-
#password ⇒ Object
Returns the value of attribute password.
-
#server ⇒ Object
Returns the value of attribute server.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #clear_changes ⇒ Object
- #connection ⇒ Object
-
#initialize(options) ⇒ Account
constructor
A new instance of Account.
- #mark_for_deletion ⇒ Object
- #marked_for_deletion? ⇒ Boolean
- #modified? ⇒ Boolean
- #multi_fetch_size ⇒ Object
- #multi_fetch_size=(value) ⇒ Object
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Account
Returns a new instance of Account.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/imap/backup/account.rb', line 13 def initialize() @username = [:username] @password = [:password] @local_path = [:local_path] @folders = [:folders] @server = [:server] @connection_options = [:connection_options] @multi_fetch_size = [:multi_fetch_size] @connection = nil @changes = {} @marked_for_deletion = false end |
Instance Attribute Details
#changes ⇒ Object (readonly)
Returns the value of attribute changes.
11 12 13 |
# File 'lib/imap/backup/account.rb', line 11 def changes @changes end |
#connection_options ⇒ Object
Returns the value of attribute connection_options.
10 11 12 |
# File 'lib/imap/backup/account.rb', line 10 def @connection_options end |
#folders ⇒ Object
Returns the value of attribute folders.
8 9 10 |
# File 'lib/imap/backup/account.rb', line 8 def folders @folders end |
#local_path ⇒ Object
Returns the value of attribute local_path.
7 8 9 |
# File 'lib/imap/backup/account.rb', line 7 def local_path @local_path end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/imap/backup/account.rb', line 6 def password @password end |
#server ⇒ Object
Returns the value of attribute server.
9 10 11 |
# File 'lib/imap/backup/account.rb', line 9 def server @server end |
#username ⇒ Object
Returns the value of attribute username.
5 6 7 |
# File 'lib/imap/backup/account.rb', line 5 def username @username end |
Instance Method Details
#clear_changes ⇒ Object
38 39 40 |
# File 'lib/imap/backup/account.rb', line 38 def clear_changes @changes = {} end |
#connection ⇒ Object
26 27 28 |
# File 'lib/imap/backup/account.rb', line 26 def connection @connection ||= Account::Connection.new(self) end |
#mark_for_deletion ⇒ Object
42 43 44 |
# File 'lib/imap/backup/account.rb', line 42 def mark_for_deletion @marked_for_deletion = true end |
#marked_for_deletion? ⇒ Boolean
46 47 48 |
# File 'lib/imap/backup/account.rb', line 46 def marked_for_deletion? @marked_for_deletion end |
#modified? ⇒ Boolean
34 35 36 |
# File 'lib/imap/backup/account.rb', line 34 def modified? changes.any? end |
#multi_fetch_size ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/imap/backup/account.rb', line 87 def multi_fetch_size int = @multi_fetch_size.to_i if int.positive? int else DEFAULT_MULTI_FETCH_SIZE end end |
#multi_fetch_size=(value) ⇒ Object
96 97 98 99 100 |
# File 'lib/imap/backup/account.rb', line 96 def multi_fetch_size=(value) parsed = value.to_i parsed = DEFAULT_MULTI_FETCH_SIZE if !parsed.positive? update(:multi_fetch_size, parsed) end |
#to_h ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/imap/backup/account.rb', line 50 def to_h h = {username: @username, password: @password} h[:local_path] = @local_path if @local_path h[:folders] = @folders if @folders h[:server] = @server if @server h[:connection_options] = @connection_options if @connection_options h[:multi_fetch_size] = multi_fetch_size if @multi_fetch_size h end |
#valid? ⇒ Boolean
30 31 32 |
# File 'lib/imap/backup/account.rb', line 30 def valid? username && password ? true : false end |