Class: Lafcadio::DateField

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

Overview

DateField represents a Date.

Direct Known Subclasses

MonthField

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, #prev_value, #process_before_verify, #verify, #verify_non_nil_value

Constructor Details

#initialize(domain_class, name = "date") ⇒ DateField

Returns a new instance of DateField.



252
253
254
# File 'lib/lafcadio/objectField.rb', line 252

def initialize( domain_class, name = "date" )
	super( domain_class, name )
end

Class Method Details

.mock_valueObject

:nodoc:



10
11
12
# File 'lib/lafcadio/test.rb', line 10

def DateField.mock_value #:nodoc:
	Date.today
end

.value_typeObject

:nodoc:



248
249
250
# File 'lib/lafcadio/objectField.rb', line 248

def self.value_type # :nodoc:
	Date
end

Instance Method Details

#value_for_sql(value) ⇒ Object

:nodoc:



256
257
258
# File 'lib/lafcadio/objectField.rb', line 256

def value_for_sql(value) # :nodoc:
	value ? "'#{value.to_s}'" : 'null'
end

#value_from_sql(dbiDate) ⇒ Object

:nodoc:



260
261
262
263
264
265
266
# File 'lib/lafcadio/objectField.rb', line 260

def value_from_sql( dbiDate ) # :nodoc:
	begin
		dbiDate ? dbiDate.to_date : nil
	rescue ArgumentError
		nil
	end
end