Module: CanonicalEmails::GMail

Defined in:
lib/canonical-emails/gmail.rb

Class Method Summary collapse

Class Method Details

.transform(value) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/canonical-emails/gmail.rb', line 4

def self.transform(value)
  Mail::Address.new(value).tap do |email|
    if email.domain && [ "gmail.com" ].include?(email.domain.downcase)
      email.instance_eval do
        def get_local
          value = super
          value.gsub(".", "").downcase if value
        end
        def domain
          value = super
          value.downcase if value
        end
      end
    end if value
  end
end