Class: EmailSpec::AddressConverter
- Inherits:
-
Object
- Object
- EmailSpec::AddressConverter
- Includes:
- Singleton
- Defined in:
- lib/email_spec/address_converter.rb
Instance Attribute Summary collapse
-
#converter ⇒ Object
Returns the value of attribute converter.
Instance Method Summary collapse
-
#conversion(&block) ⇒ Object
The block provided to conversion should convert to an email address string or return the input untouched.
- #convert(input) ⇒ Object
Instance Attribute Details
#converter ⇒ Object
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 |