Class: Mayaml::MailAccount::SmtpProtocolValidator
- Inherits:
-
Object
- Object
- Mayaml::MailAccount::SmtpProtocolValidator
- Defined in:
- lib/mayaml/mail_account/smtp_protocol_validator.rb
Constant Summary collapse
- VALID_TYPES =
[:smtp, :smtps].freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(type) ⇒ SmtpProtocolValidator
constructor
A new instance of SmtpProtocolValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(type) ⇒ SmtpProtocolValidator
Returns a new instance of SmtpProtocolValidator.
27 28 29 30 31 32 33 34 |
# File 'lib/mayaml/mail_account/smtp_protocol_validator.rb', line 27 def initialize(type) @errors = [] type = type.to_sym if type.respond_to? :to_sym unless VALID_TYPES.include?(type) types = VALID_TYPES.join(", ") @errors << "Mail account smtp_protocol is invalid. Allowed types: #{types}." end end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
24 25 26 |
# File 'lib/mayaml/mail_account/smtp_protocol_validator.rb', line 24 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
36 37 38 |
# File 'lib/mayaml/mail_account/smtp_protocol_validator.rb', line 36 def valid? @errors.empty? end |