Class: Imap::Backup::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/account.rb,
lib/imap/backup/account/folder.rb,
lib/imap/backup/account/connection.rb

Defined Under Namespace

Classes: Connection, Folder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Account

Returns a new instance of Account.



12
13
14
15
16
17
18
19
20
21
# File 'lib/imap/backup/account.rb', line 12

def initialize(options)
  @username = options[:username]
  @password = options[:password]
  @local_path = options[:local_path]
  @folders = options[:folders]
  @server = options[:server]
  @connection_options = options[:connection_options]
  @changes = {}
  @marked_for_deletion = false
end

Instance Attribute Details

#changesObject (readonly)

Returns the value of attribute changes.



9
10
11
# File 'lib/imap/backup/account.rb', line 9

def changes
  @changes
end

#connection_optionsObject

Returns the value of attribute connection_options.



8
9
10
# File 'lib/imap/backup/account.rb', line 8

def connection_options
  @connection_options
end

#foldersObject

Returns the value of attribute folders.



6
7
8
# File 'lib/imap/backup/account.rb', line 6

def folders
  @folders
end

#local_pathObject

Returns the value of attribute local_path.



5
6
7
# File 'lib/imap/backup/account.rb', line 5

def local_path
  @local_path
end

#marked_for_deletionObject (readonly)

Returns the value of attribute marked_for_deletion.



10
11
12
# File 'lib/imap/backup/account.rb', line 10

def marked_for_deletion
  @marked_for_deletion
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/imap/backup/account.rb', line 4

def password
  @password
end

#serverObject

Returns the value of attribute server.



7
8
9
# File 'lib/imap/backup/account.rb', line 7

def server
  @server
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/imap/backup/account.rb', line 3

def username
  @username
end

Instance Method Details

#clear_changes!Object



35
36
37
# File 'lib/imap/backup/account.rb', line 35

def clear_changes!
  @changes = {}
end

#connectionObject



23
24
25
# File 'lib/imap/backup/account.rb', line 23

def connection
  ::Connection.new(self)
end

#mark_for_deletion!Object



39
40
41
# File 'lib/imap/backup/account.rb', line 39

def mark_for_deletion!
  @marked_for_deletion = true
end

#marked_for_deletion?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/imap/backup/account.rb', line 43

def marked_for_deletion?
  @marked_for_deletion
end

#modified?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/imap/backup/account.rb', line 31

def modified?
  changes.any?
end

#to_hObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/imap/backup/account.rb', line 47

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
end

#valid?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/imap/backup/account.rb', line 27

def valid?
  username && password
end