Class: Momomoto::Datatype::Date
- Defined in:
- lib/momomoto/datatype/date.rb
Overview
Represents the data type Date.
Instance Method Summary collapse
-
#filter_set(value) ⇒ Object
Values are filtered by this function when being set.
Methods inherited from Base
#compile_rule, #default, #default_operator, #equal, #escape, #initialize, #not_null?, operator_sign
Constructor Details
This class inherits a constructor from Momomoto::Datatype::Base
Instance Method Details
#filter_set(value) ⇒ Object
Values are filtered by this function when being set. Returns ruby’s Date or tries to build a Date from a String. Raises ConversionError if the given value
cannot be parsed.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/momomoto/datatype/date.rb', line 13 def filter_set( value ) case value when nil,'' then nil when ::Date then value when String then ::Date.parse( value, '%Y-%m-%d' ) else raise Error end rescue => e raise ConversionError, "parse Error in Date #{e}" end |