Sha256: a30101f5c48a1ab88cbc732f0c69cc9222e4df2d244db20b709d6d2012866b5a
Contents?: true
Size: 1.51 KB
Versions: 1
Compression:
Stored size: 1.51 KB
Contents
# frozen_string_literal: true # Copyright (C) 2017 Szymon Kopciewski # # This file is part of Mayaml. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. module Mayaml class MailAccount class MailboxesValidator def initialize(mailboxes) @mailboxes = mailboxes errors << "Mailboxes should be array." unless right_mailboxes_type? errors << "Mailboxes can not be empty." unless mailboxes_exists? errors << "Mailboxes should all be strings." unless right_mailboxes_content? end def valid? errors.empty? end def errors @errors ||= [] end private def right_mailboxes_type? @mailboxes.instance_of? Array end def mailboxes_exists? right_mailboxes_type? && !@mailboxes.empty? end def right_mailboxes_content? right_mailboxes_type? && @mailboxes.all? { |box| box.instance_of? String } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mayaml-4.0.0 | lib/mayaml/mail_account/mailboxes_validator.rb |