class MailHandler::Receiving::Checker
Email receiving checker main class. @see MailHandler::Receiving::FolderChecker
for example for one of implemented checkers.
Constants
- AVAILABLE_SEARCH_OPTIONS
Attributes
available_search_options[RW]
found_emails[RW]
search_options[RW]
Public Class Methods
new()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 16 def initialize @available_search_options = AVAILABLE_SEARCH_OPTIONS set_base_search_options reset_found_emails end
Public Instance Methods
find(_options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 26 def find(_options) raise MailHandler::InterfaceError, 'Find interface not implemented.' end
reset_found_emails()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 34 def reset_found_emails @found_emails = [] end
search_result()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 30 def search_result !found_emails.empty? end
start()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 22 def start; end
stop()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 24 def stop; end
Protected Instance Methods
add_additional_search_options(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 107 def add_additional_search_options(options) @search_options = @search_options.merge options end
set_base_search_options()
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 102 def set_base_search_options # Default number of email results to return, and whether to archive emails. @search_options = { count: 50, archive: false } end
validate_archive_option(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 74 def validate_archive_option(options) return if options[:archive].nil? error_message = "Incorrect option options[:archive]=#{options[:archive]}." raise MailHandler::Error, error_message unless [true, false].include?(options[:archive]) end
validate_count_option(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 88 def validate_count_option(options) return if options[:count].nil? count = options[:count] error_message = "Incorrect option options[:count]=#{options[:count]}." raise MailHandler::Error, error_message if (count < 0) || (count > 2000) end
validate_option_values(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 60 def validate_option_values(options) validate_since_option(options) validate_count_option(options) validate_archive_option(options) validate_recipient_option(options) end
validate_recipient_option(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 67 def validate_recipient_option(options) return if options[:by_recipient].nil? error_message = "Incorrect option options[:by_recipient]=#{options[:by_recipient]}." raise MailHandler::Error, error_message unless options[:by_recipient].is_a?(Hash) end
validate_since_option(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 81 def validate_since_option(options) return if options[:since].nil? error_message = "Incorrect option options[:since]=#{options[:since]}." raise MailHandler::Error, error_message unless options[:since].is_a?(Time) end
validate_used_options(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 96 def validate_used_options(options) error_message = "#{(options.keys - available_search_options)} - Incorrect search option values,"\ " options are #{available_search_options}." raise MailHandler::Error, error_message unless (options.keys - available_search_options).empty? end
verify_and_set_search_options(options)
click to toggle source
# File lib/mailhandler/receiving/base.rb, line 51 def verify_and_set_search_options(options) validate_used_options(options) validate_option_values(options) set_base_search_options add_additional_search_options(options) reset_found_emails end