Class: Mayaml::MailAccount::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/mayaml/mail_account/builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



37
38
39
# File 'lib/mayaml/mail_account/builder.rb', line 37

def initialize
  @account = ::Mayaml::MailAccount.new
end

Class Method Details

.build {|builder| ... } ⇒ Object

Yields:

  • (builder)


31
32
33
34
35
# File 'lib/mayaml/mail_account/builder.rb', line 31

def self.build
  builder = new
  yield(builder)
  builder.
end

Instance Method Details

#accountObject



107
108
109
110
111
# File 'lib/mayaml/mail_account/builder.rb', line 107

def 
  obj = 
  @account = ::Mayaml::MailAccount.new
  obj
end

#default(flag) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/mayaml/mail_account/builder.rb', line 45

def default(flag)
  if flag.nil? || flag == ""
    @account.set_default_flag
  else
    valid_attribute DefaultFlagValidator, WrongDefaultFlag, flag
    @account.default = (["true", true].include? flag)
  end
end

#mailboxes(arr) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/mayaml/mail_account/builder.rb', line 80

def mailboxes(arr)
  if arr.nil? || arr.empty?
    @account.set_default_mailboxes
  else
    valid_attribute MailboxesValidator, WrongAccountMailboxes, arr
    @account.mailboxes = arr
  end
end

#name(name) ⇒ Object



41
42
43
# File 'lib/mayaml/mail_account/builder.rb', line 41

def name(name)
  @account.name = name
end

#pass(str) ⇒ Object



76
77
78
# File 'lib/mayaml/mail_account/builder.rb', line 76

def pass(str)
  @account.pass = str
end

#port(nr) ⇒ Object



67
68
69
70
# File 'lib/mayaml/mail_account/builder.rb', line 67

def port(nr)
  valid_attribute PortValidator, WrongAccountPort, nr
  @account.port = nr.to_i
end

#realname(realname) ⇒ Object



54
55
56
# File 'lib/mayaml/mail_account/builder.rb', line 54

def realname(realname)
  @account.realname = realname
end

#server(str) ⇒ Object



63
64
65
# File 'lib/mayaml/mail_account/builder.rb', line 63

def server(str)
  @account.server = str
end

#smtp_authenticator(str) ⇒ Object



99
100
101
# File 'lib/mayaml/mail_account/builder.rb', line 99

def smtp_authenticator(str)
  @account.smtp_authenticator = str
end

#smtp_port(nr) ⇒ Object



94
95
96
97
# File 'lib/mayaml/mail_account/builder.rb', line 94

def smtp_port(nr)
  valid_attribute PortValidator, WrongAccountSmtpPort, nr
  @account.smtp_port = nr.to_i
end

#smtp_protocol(str) ⇒ Object



89
90
91
92
# File 'lib/mayaml/mail_account/builder.rb', line 89

def smtp_protocol(str)
  valid_attribute SmtpProtocolValidator, WrongAccountSmtpProtocol, str
  @account.smtp_protocol = str.to_sym
end

#smtp_server(str) ⇒ Object



103
104
105
# File 'lib/mayaml/mail_account/builder.rb', line 103

def smtp_server(str)
  @account.smtp_server = str
end

#type(str) ⇒ Object



58
59
60
61
# File 'lib/mayaml/mail_account/builder.rb', line 58

def type(str)
  valid_attribute TypeValidator, WrongAccountType, str
  @account.type = str.to_sym
end

#user(str) ⇒ Object



72
73
74
# File 'lib/mayaml/mail_account/builder.rb', line 72

def user(str)
  @account.user = str
end