module Normailize::Provider
Public: Module to give email provider classes default functionality
Public Class Methods
Internal: Create a provider instance from a domain
domain - A domain for an email provider, like gmail.com
Returns an instance of a provider that recognizes the domain or a generic provider
# File lib/normailize/provider.rb, line 12 def self.factory(domain) case domain when *Gmail.domains then Gmail.new(domain) when *Live.domains then Live.new(domain) when *Hotmail.domains then Hotmail.new(domain) else Generic.new(domain) end end
# File lib/normailize/provider.rb, line 21 def self.included(base) class << base; attr_accessor :domains, :modifications end base.extend(ClassMethods) end
Public: Class initializer
domain - A domain like gmail.com
Returns nothing
# File lib/normailize/provider.rb, line 66 def initialize(domain) @domain = domain end
Public Instance Methods
Internal: Get the domain that the provider was instantiated with
Returns domain
# File lib/normailize/provider.rb, line 81 def domain @domain end
Internal: Determine if a provider is generic or not
Returns true if generic or false if not
# File lib/normailize/provider.rb, line 88 def generic? self.is_a?(Normailize::Provider::Generic) end
Internal: Get all modification rules for the provider
Returns symbols that tell the email class how to normalize an address for the provider
# File lib/normailize/provider.rb, line 74 def modifications self.class.modifications || [] end
Internal: Determine if two providers are the same or not
provider - An instance of another provider class
Returns true if providers are the same or false if not
# File lib/normailize/provider.rb, line 97 def same_as?(provider) if self.generic? || provider.generic? @domain == provider.domain else self.class == provider.class end end