class Mayaml::MailAccount::Builder
Public Class Methods
build() { |builder| ... }
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 31 def self.build builder = new yield(builder) builder.account end
new()
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 37 def initialize @account = ::Mayaml::MailAccount.new end
Public Instance Methods
account()
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 107 def account obj = valid_account @account = ::Mayaml::MailAccount.new obj end
default(flag)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 41 def name(name) @account.name = name end
pass(str)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 76 def pass(str) @account.pass = str end
port(nr)
click to toggle source
# 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)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 54 def realname(realname) @account.realname = realname end
server(str)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 63 def server(str) @account.server = str end
smtp_authenticator(str)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 99 def smtp_authenticator(str) @account.smtp_authenticator = str end
smtp_port(nr)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 103 def smtp_server(str) @account.smtp_server = str end
type(str)
click to toggle source
# 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)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 72 def user(str) @account.user = str end
Private Instance Methods
valid_account()
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 115 def valid_account validator = RequiredAttributesValidator.new @account raise MissingAttributes, validator.errors.join(" ") unless validator.valid? @account.dup end
valid_attribute(validator_class, error_class, attribute)
click to toggle source
# File lib/mayaml/mail_account/builder.rb, line 121 def valid_attribute(validator_class, error_class, attribute) validator = validator_class.new attribute raise error_class, validator.errors.join(" ") unless validator.valid? end