Class: Common::HTTPDate

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#coerce(value) ⇒ Object



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

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

  value.httpdate
end