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.



5
6
7
# File 'lib/email_spec/address_converter.rb', line 5

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


18
19
20
# File 'lib/email_spec/address_converter.rb', line 18

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

#convert(input) ⇒ Object



22
23
24
25
# File 'lib/email_spec/address_converter.rb', line 22

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