Module: EmailDomainChecker
- Defined in:
- lib/email_domain_checker.rb,
lib/email_domain_checker/cache.rb,
lib/email_domain_checker/config.rb,
lib/email_domain_checker/checker.rb,
lib/email_domain_checker/version.rb,
lib/email_domain_checker/normalizer.rb,
lib/email_domain_checker/dns_resolver.rb,
lib/email_domain_checker/domain_validator.rb,
lib/email_domain_checker/cache/base_adapter.rb,
lib/email_domain_checker/cache/redis_adapter.rb,
lib/email_domain_checker/cache/memory_adapter.rb,
lib/email_domain_checker/email_address_adapter.rb,
lib/email_domain_checker/active_model_validator.rb
Defined Under Namespace
Modules: Cache Classes: Checker, Config, DnsResolver, DomainCheckValidator, DomainValidator, EmailAddressAdapter, Error, Normalizer
Constant Summary collapse
- VERSION =
"0.1.4"
Class Method Summary collapse
-
.cache ⇒ Cache::BaseAdapter?
Get cache adapter instance (returns nil if cache is disabled).
-
.clear_cache ⇒ Object
Clear all cached DNS validation results.
-
.clear_cache_for_domain(domain) ⇒ Object
Clear cached DNS validation results for a specific domain.
-
.configure(options = {}, &block) ⇒ Object
Configure default options.
-
.domain_valid?(email, options = {}) ⇒ Boolean
Convenience method for domain validation only.
-
.format_valid?(email) ⇒ Boolean
Convenience method for format validation only.
-
.normalize(email) ⇒ Object
Convenience method for normalization.
-
.valid?(email, options = {}) ⇒ Boolean
Convenience method for quick validation.
-
.with_cache(key, ttl: nil, force: false) { ... } ⇒ Object
Convenience method for cache.with (Rails-style) Only works if cache is enabled.
Class Method Details
.cache ⇒ Cache::BaseAdapter?
Get cache adapter instance (returns nil if cache is disabled)
63 64 65 |
# File 'lib/email_domain_checker.rb', line 63 def self.cache Config.cache_adapter end |
.clear_cache ⇒ Object
Clear all cached DNS validation results
52 53 54 |
# File 'lib/email_domain_checker.rb', line 52 def self.clear_cache Config.clear_cache end |
.clear_cache_for_domain(domain) ⇒ Object
Clear cached DNS validation results for a specific domain
57 58 59 |
# File 'lib/email_domain_checker.rb', line 57 def self.clear_cache_for_domain(domain) Config.clear_cache_for_domain(domain) end |
.configure(options = {}, &block) ⇒ Object
Configure default options
47 48 49 |
# File 'lib/email_domain_checker.rb', line 47 def self.configure( = {}, &block) Config.configure(, &block) end |
.domain_valid?(email, options = {}) ⇒ Boolean
Convenience method for domain validation only
37 38 39 |
# File 'lib/email_domain_checker.rb', line 37 def self.domain_valid?(email, = {}) Checker.new(email, validate_format: false, **).domain_valid? end |
.format_valid?(email) ⇒ Boolean
Convenience method for format validation only
32 33 34 |
# File 'lib/email_domain_checker.rb', line 32 def self.format_valid?(email) Checker.new(email, validate_domain: false).format_valid? end |
.normalize(email) ⇒ Object
Convenience method for normalization
42 43 44 |
# File 'lib/email_domain_checker.rb', line 42 def self.normalize(email) Normalizer.normalize(email) end |
.valid?(email, options = {}) ⇒ Boolean
Convenience method for quick validation
27 28 29 |
# File 'lib/email_domain_checker.rb', line 27 def self.valid?(email, = {}) Checker.new(email, ).valid? end |
.with_cache(key, ttl: nil, force: false) { ... } ⇒ Object
Convenience method for cache.with (Rails-style) Only works if cache is enabled
75 76 77 78 79 80 |
# File 'lib/email_domain_checker.rb', line 75 def self.with_cache(key, ttl: nil, force: false, &block) adapter = cache raise ArgumentError, "Cache is not enabled. Please enable cache in configuration." unless adapter adapter.with(key, ttl: ttl, force: force, &block) end |