Class: Lafcadio::EmailField
- Inherits:
-
StringField
- Object
- ObjectField
- StringField
- Lafcadio::EmailField
- Defined in:
- lib/lafcadio/objectField.rb
Overview
EmailField takes a text value that is expected to be formatted as a single valid email address.
Instance Attribute Summary
Attributes inherited from ObjectField
#db_field_name, #domain_class, #mock_value, #name, #not_nil
Class Method Summary collapse
-
.mock_value ⇒ Object
:nodoc:.
-
.valid_address(address) ⇒ Object
Is
address
a valid email address?.
Instance Method Summary collapse
-
#initialize(domain_class, name = "email") ⇒ EmailField
constructor
A new instance of EmailField.
-
#verify_non_nil_value(value, pk_id) ⇒ Object
:nodoc:.
Methods inherited from StringField
Methods inherited from ObjectField
#<=>, #bind_write?, create_from_xml, create_with_args, creation_parameters, #db_column, #db_will_automatically_write?, #default_mock_value, #prev_value, #process_before_verify, #value_for_sql, #value_from_sql, value_type, #verify
Constructor Details
#initialize(domain_class, name = "email") ⇒ EmailField
Returns a new instance of EmailField.
393 394 395 |
# File 'lib/lafcadio/objectField.rb', line 393 def initialize( domain_class, name = "email" ) super( domain_class, name ) end |
Class Method Details
.mock_value ⇒ Object
:nodoc:
311 312 313 |
# File 'lib/lafcadio/test.rb', line 311 def EmailField.mock_value #:nodoc: '[email protected]' end |
.valid_address(address) ⇒ Object
Is address
a valid email address?
389 390 391 |
# File 'lib/lafcadio/objectField.rb', line 389 def self.valid_address(address) address =~ /^[^ @]+@[^ \.]+\.[^ ,]+$/ end |
Instance Method Details
#verify_non_nil_value(value, pk_id) ⇒ Object
:nodoc:
397 398 399 400 401 402 403 404 405 406 |
# File 'lib/lafcadio/objectField.rb', line 397 def verify_non_nil_value(value, pk_id) #:nodoc: super(value, pk_id) if !EmailField.valid_address(value) raise( FieldValueError, "#{ domain_class.name }##{ name } needs a valid email address.", caller ) end end |