module FmRest::StringDateAwareness

Public Class Methods

enable(classes: [Date, DateTime]) click to toggle source
# File lib/fmrest/string_date.rb, line 216
def self.enable(classes: [Date, DateTime])
  classes.each { |klass| klass.singleton_class.prepend(self) }
end

Public Instance Methods

===(other) click to toggle source

Overriding case equality method so that it returns true for `FmRest::StringDate` instances

Calls superclass method

Calls superclass method
# File lib/fmrest/string_date.rb, line 212
def ===(other)
  super || other.is_a?(StringDate)
end
_parse(v, *_) click to toggle source
Calls superclass method
# File lib/fmrest/string_date.rb, line 190
def _parse(v, *_)
  if v.is_a?(StringDateTime)
    return { year: v.year, mon: v.month, mday: v.mday, hour: v.hour, min: v.min, sec: v.sec, sec_fraction: v.sec_fraction, offset: v.offset }
  end
  if v.is_a?(StringDate)
    return { year: v.year, mon: v.month, mday: v.mday }
  end
  super
end
parse(v, *_) click to toggle source
Calls superclass method
# File lib/fmrest/string_date.rb, line 200
def parse(v, *_)
  if v.is_a?(StringDate)
    return self == ::DateTime ? v.to_datetime : v.to_date
  end
  super
end