Class: Lafcadio::TextListField
- Inherits:
-
ObjectField
- Object
- ObjectField
- Lafcadio::TextListField
- Defined in:
- lib/lafcadio/objectField.rb
Overview
TextListField maps to any String SQL field that tries to represent a quick-and-dirty list with a comma-separated string. It returns an Array. For example, a SQL field with the value “john,bill,dave”, then the Ruby field will have the value [ "john", "bill", "dave" ]
.
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:.
-
.value_type ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#value_for_sql(objectValue) ⇒ Object
:nodoc:.
-
#value_from_sql(sqlString, lookupLink = true) ⇒ Object
:nodoc:.
Methods inherited from ObjectField
#<=>, #bind_write?, create_from_xml, create_with_args, creation_parameters, #db_column, #db_will_automatically_write?, #default_mock_value, #initialize, #prev_value, #process_before_verify, #verify, #verify_non_nil_value
Constructor Details
This class inherits a constructor from Lafcadio::ObjectField
Class Method Details
.mock_value ⇒ Object
:nodoc:
339 340 341 |
# File 'lib/lafcadio/test.rb', line 339 def TextListField.mock_value #:nodoc: %w( a b c ) end |
.value_type ⇒ Object
:nodoc:
542 543 544 |
# File 'lib/lafcadio/objectField.rb', line 542 def self.value_type #:nodoc: Array end |
Instance Method Details
#value_for_sql(objectValue) ⇒ Object
:nodoc:
546 547 548 549 550 551 552 553 |
# File 'lib/lafcadio/objectField.rb', line 546 def value_for_sql(objectValue) #:nodoc: if objectValue.is_a?( Array ) str = objectValue.join(',') else str = objectValue end "'" + str + "'" end |
#value_from_sql(sqlString, lookupLink = true) ⇒ Object
:nodoc:
555 556 557 558 559 560 561 |
# File 'lib/lafcadio/objectField.rb', line 555 def value_from_sql(sqlString, lookupLink = true) #:nodoc: if sqlString sqlString.split ',' else [] end end |