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