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.



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

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

Class Method Details

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

Yields:

  • (builder)


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

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

Instance Method Details

#accountObject



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

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

#default(flag) ⇒ Object



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

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



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

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



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

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

#pass(str) ⇒ Object



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

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

#port(nr) ⇒ Object



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

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

#realname(realname) ⇒ Object



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

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

#server(str) ⇒ Object



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

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

#type(str) ⇒ Object



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

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

#user(str) ⇒ Object



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

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