Class: Momomoto::Datatype::Timestamp_without_time_zone
- Defined in:
- lib/momomoto/datatype/timestamp_without_time_zone.rb
Overview
Represents the data type Timestamp without time zone.
Direct Known Subclasses
Instance Method Summary collapse
-
#escape(value) ⇒ Object
Escapes
value
to be saved in database. -
#filter_set(value) ⇒ Object
Values are filtered by this function when being set.
Methods inherited from Base
#compile_rule, #default, #default_operator, #equal, #initialize, #not_null?, operator_sign
Constructor Details
This class inherits a constructor from Momomoto::Datatype::Base
Instance Method Details
#escape(value) ⇒ Object
Escapes value
to be saved in database.
11 12 13 14 15 16 17 |
# File 'lib/momomoto/datatype/timestamp_without_time_zone.rb', line 11 def escape( value ) case value when nil then 'NULL' when String then Database.quote(value) else Database.quote(value.strftime('%Y-%m-%d %H:%M:%S')) end end |
#filter_set(value) ⇒ Object
Values are filtered by this function when being set. Returns an instance of Time or nil if value
is nil or empty.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/momomoto/datatype/timestamp_without_time_zone.rb', line 21 def filter_set( value ) case value when nil, '' then nil when ::Time then value when String then ::Time.parse( value ) else raise Error end rescue => e raise ConversionError, "Error while parsing Timestamp" end |