Module: MarkMapper::Extensions::Date

Included in:
Date
Defined in:
lib/mark_mapper/extensions/date.rb

Instance Method Summary collapse

Instance Method Details

#from_marklogic(value) ⇒ Object


16
17
18
# File 'lib/mark_mapper/extensions/date.rb', line 16

def from_marklogic(value)
  value.to_date if value
end

#to_marklogic(value) ⇒ Object


5
6
7
8
9
10
11
12
13
14
# File 'lib/mark_mapper/extensions/date.rb', line 5

def to_marklogic(value)
  if value.nil? || (value.instance_of?(String) && '' === value)
    nil
  else
    date = value.instance_of?(::Date) || value.instance_of?(::Time) ? value : ::Date.parse(value.to_s)
    ::Time.utc(date.year, date.month, date.day)
  end
rescue
  nil
end

#xs_typeObject


20
21
22
# File 'lib/mark_mapper/extensions/date.rb', line 20

def xs_type
  "date"
end