Class: Lafcadio::AutoIncrementField

Inherits:
IntegerField show all
Defined in:
lib/lafcadio/objectField/AutoIncrementField.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes inherited from ObjectField

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

Instance Method Summary collapse

Methods inherited from IntegerField

#textBoxSize, #valueFromSQL

Methods inherited from ObjectField

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

Constructor Details

#initialize(objectType, name, englishName = nil) ⇒ AutoIncrementField

Returns a new instance of AutoIncrementField.



7
8
9
10
# File 'lib/lafcadio/objectField/AutoIncrementField.rb', line 7

def initialize(objectType, name, englishName = nil)
	super(objectType, name, englishName)
	@objectType = objectType
end

Instance Attribute Details

#objectTypeObject (readonly)

Returns the value of attribute objectType.



5
6
7
# File 'lib/lafcadio/objectField/AutoIncrementField.rb', line 5

def objectType
  @objectType
end

Instance Method Details

#HTMLWidgetValueStr(value) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/lafcadio/objectField/AutoIncrementField.rb', line 12

def HTMLWidgetValueStr(value)
	if value != nil
		super value
	else
		highestValue = 0
		ObjectStore.getObjectStore.getAll(objectType).each { |obj|
			aValue = obj.send(name).to_i
			highestValue = aValue if aValue > highestValue
		}
	 (highestValue + 1).to_s
	end
end