Module: EmailAddressExtension
- Defined in:
- lib/email_address_extension.rb
Instance Method Summary collapse
-
#as_json(*_opts) ⇒ Object
Using alias_method doesn’t really work here, so we’ll just override the methods.
-
#initialize(email_address, config = {}, locale = "en") ⇒ Object
The email_address gem has a couple of undesired behaviors we need to work around: - It checks the MX record of the domain, which is not necessary for our use-case - as_json/to_json output a huge hash/object, but we just want the email address as a string.
- #to_json(*_opts) ⇒ Object
Instance Method Details
#as_json(*_opts) ⇒ Object
Using alias_method doesn’t really work here, so we’ll just override the methods
17 18 19 |
# File 'lib/email_address_extension.rb', line 17 def as_json(*_opts) to_s end |
#initialize(email_address, config = {}, locale = "en") ⇒ Object
The email_address gem has a couple of undesired behaviors we need to work around:
-
It checks the MX record of the domain, which is not necessary for our use-case
-
as_json/to_json output a huge hash/object, but we just want the email address as a string
9 10 11 12 13 14 |
# File 'lib/email_address_extension.rb', line 9 def initialize(email_address, config = {}, locale = "en") config[:dns_lookup] = :off config[:host_validation] = :syntax super end |
#to_json(*_opts) ⇒ Object
21 22 23 |
# File 'lib/email_address_extension.rb', line 21 def to_json(*_opts) to_s end |