Class: Lafcadio::TextListField

Inherits:
ObjectField show all
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

Instance Method Summary collapse

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_valueObject

:nodoc:



332
333
334
# File 'lib/lafcadio/test.rb', line 332

def TextListField.mock_value #:nodoc:
	%w( a b c )
end

.value_typeObject

:nodoc:



553
554
555
# File 'lib/lafcadio/objectField.rb', line 553

def self.value_type #:nodoc:
	Array
end

Instance Method Details

#value_for_sql(objectValue) ⇒ Object

:nodoc:



557
558
559
560
561
562
563
564
# File 'lib/lafcadio/objectField.rb', line 557

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:



566
567
568
569
570
571
572
# File 'lib/lafcadio/objectField.rb', line 566

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