Skip to content

Commit

Permalink
Remove memoization from DomainListMatch#whitelisted_domain? (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
bestwebua authored Jun 27, 2019
1 parent a969133 commit db5d59d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
truemail (1.2.0)
truemail (1.2.1)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/validate/domain_list_match.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion lib/truemail/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Truemail
VERSION = '1.2.0'
VERSION = '1.2.1'
end

0 comments on commit db5d59d

Please sign in to comment.