From db5d59dd132bb830e04a6723ff1117d5b07e39d3 Mon Sep 17 00:00:00 2001 From: Vladislav Trotsenko Date: Thu, 27 Jun 2019 12:36:55 +0300 Subject: [PATCH] Remove memoization from DomainListMatch#whitelisted_domain? (#53) --- Gemfile.lock | 2 +- README.md | 6 +++++- lib/truemail/validate/domain_list_match.rb | 2 +- lib/truemail/version.rb | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3a6a9ad..b094e27 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - truemail (1.2.0) + truemail (1.2.1) GEM remote: https://rubygems.org/ diff --git a/README.md b/README.md index 57ba9a9..d244e45 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Or install it yourself as: ## Email Validation Methods -Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation. +Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation. You can get more information about email validation techniques in our [blog](https://rubygarage.org/blog/how-to-validate-emails). **Syntax Checking**: Checks the email addresses via regex pattern. @@ -84,19 +84,23 @@ Truemail.configure do |config| # This configuration will be used over current or default validation type parameter # All of validations for 'somedomain.com' will be processed with regex validation only. # And all of validations for 'otherdomain.com' will be processed with mx validation only. + # It is equal to empty hash by default. config.validation_type_for = { 'somedomain.com' => :regex, 'otherdomain.com' => :mx } # Optional parameter. Validation of email which contains whitelisted domain always will # return true. Other validations will not processed even if it was defined in validation_type_for + # It is equal to empty array by default. config.whitelisted_domains = ['somedomain1.com', 'somedomain2.com'] # Optional parameter. With this option Truemail will validate email which contains whitelisted # domain only, i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP validators. # Validation of email which not contains whitelisted domain always will return false. + # It is equal false by default. config.whitelist_validation = true # Optional parameter. Validation of email which contains blacklisted domain always will # return false. Other validations will not processed even if it was defined in validation_type_for + # It is equal to empty array by default. config.blacklisted_domains = ['somedomain1.com', 'somedomain2.com'] # Optional parameter. This option will be parse bodies of SMTP errors. It will be helpful diff --git a/lib/truemail/validate/domain_list_match.rb b/lib/truemail/validate/domain_list_match.rb index 94787c2..72c4cc6 100644 --- a/lib/truemail/validate/domain_list_match.rb +++ b/lib/truemail/validate/domain_list_match.rb @@ -19,7 +19,7 @@ def email_domain end def whitelisted_domain? - @whitelisted_domain ||= configuration.whitelisted_domains.include?(email_domain) + configuration.whitelisted_domains.include?(email_domain) end def whitelist_validation? diff --git a/lib/truemail/version.rb b/lib/truemail/version.rb index 33a790b..cf1385f 100644 --- a/lib/truemail/version.rb +++ b/lib/truemail/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Truemail - VERSION = '1.2.0' + VERSION = '1.2.1' end