Class: Common::UTCTime

Inherits:
Virtus::Attribute
  • Object
show all
Defined in:
lib/common/models/attribute_types/utc_time.rb

Overview

This is a custom type class for ensuring Time is always coerced as UTC

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



6
7
8
9
10
11
# File 'lib/common/models/attribute_types/utc_time.rb', line 6

def coerce(value)
  return nil if value.to_s.empty?
  return Time.parse(value).utc if value.is_a?(String)

  value.utc
end