Class: Tape::EmailSpec::AddressConverter
- Inherits:
-
Object
- Object
- Tape::EmailSpec::AddressConverter
- Includes:
- Singleton
- Defined in:
- lib/tape/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.
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 |