Class: EmailSpec::AddressConverter

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/email_spec/address_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#converterObject

Returns the value of attribute converter.



7
8
9
# File 'lib/email_spec/address_converter.rb', line 7

def converter
  @converter
end

Instance Method Details

#conversion(&block) ⇒ Object

The block provided to conversion should convert to an email address string or return the input untouched. For example:

EmailSpec::AddressConverter.instance.conversion do |input|
 if input.is_a?(User)
   input.email
 else
   input
 end
end


20
21
22
# File 'lib/email_spec/address_converter.rb', line 20

def conversion(&block)
  self.converter = block
end

#convert(input) ⇒ Object



24
25
26
27
# File 'lib/email_spec/address_converter.rb', line 24

def convert(input)
  return input unless converter
  converter.call(input)
end