class Mayaml::MailAccount::TypeValidator

Constants

VALID_TYPES

Public Class Methods

new(type) click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 25
def initialize(type)
  @type = convert_type(type)
  errors << "Mail account type is invalid. Allowed types: #{valid_types}." unless valid_type?
end

Public Instance Methods

errors() click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 34
def errors
  @errors ||= []
end
valid?() click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 30
def valid?
  errors.empty?
end

Private Instance Methods

convert_type(type) click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 40
def convert_type(type)
  type.to_sym if type.respond_to? :to_sym
end
valid_type?() click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 44
def valid_type?
  VALID_TYPES.include? @type
end
valid_types() click to toggle source
# File lib/mayaml/mail_account/type_validator.rb, line 48
def valid_types
  VALID_TYPES.join(", ")
end