Class: Lafcadio::TextListField

Inherits:
ObjectField show all
Defined in:
lib/lafcadio/objectField/TextListField.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

#dbFieldName, #default, #defaultFieldName, #hideDisplay, #hideLabel, #name, #notNull, #notUniqueMsg, #objectType, #unique, #writeOnce

Instance Method Summary collapse

Methods inherited from ObjectField

#<=>, #bind_write?, #dbWillAutomaticallyWrite, #db_table_and_field_name, #englishName, #firstTime, #initialize, instantiateFromXml, instantiateWithParameters, instantiationParameters, #nameForSQL, #nullErrorMsg, #prevValue, #processBeforeVerify, valueType, #verify, #verifyUniqueness

Constructor Details

This class inherits a constructor from Lafcadio::ObjectField

Instance Method Details

#valueForSQL(objectValue) ⇒ Object

:nodoc:



17
18
19
# File 'lib/lafcadio/objectField/TextListField.rb', line 17

def valueForSQL(objectValue) #:nodoc:
	"'" + objectValue.join(',') + "'"
end

#valueFromSQL(sqlString, lookupLink = true) ⇒ Object

:nodoc:



9
10
11
12
13
14
15
# File 'lib/lafcadio/objectField/TextListField.rb', line 9

def valueFromSQL(sqlString, lookupLink = true) #:nodoc:
	if sqlString
		sqlString.split ','
	else
		[]
	end
end