module Normailize::Provider

Public: Module to give email provider classes default functionality

Public Class Methods

factory(domain) click to toggle source

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
included(base) click to toggle source
# File lib/normailize/provider.rb, line 21
def self.included(base)
  class << base; attr_accessor :domains, :modifications end
  base.extend(ClassMethods)    
end
new(domain) click to toggle source

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

domain() click to toggle source

Internal: Get the domain that the provider was instantiated with

Returns domain

# File lib/normailize/provider.rb, line 81
def domain
  @domain
end
generic?() click to toggle source

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
modifications() click to toggle source

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
same_as?(provider) click to toggle source

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