aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

Added time_attr and time marshaler #81

Closed ghost closed 6 years ago

ghost commented 6 years ago

Description of changes:

RuboCop guidance says to avoid DateTime: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/DateTime https://github.com/rubocop-hq/rubocop/issues/1952

And additionally, the Ruby docs recommend to use Time:

https://ruby-doc.org/stdlib-2.5.1/libdoc/time/rdoc/Time.html

With DateTime, we're able to save a Time object to DynamoDB but it comes back out as a DateTime. I added a time marshaler and defined a time_attr so that we can store serialized Time objects.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

ghost commented 6 years ago

As discussed in Chime, I've removed the Date -> Time test as it's a pretty silly thing to do anyway. Anyone trying to save a Date as a Time attribute is just asking for it, and when they retrieve that record they can expect it to be a Time object anyway.