Class: Tape::EmailSpec::AddressConverter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#converterObject

Returns the value of attribute converter.



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

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


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

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

#convert(input) ⇒ Object



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

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