Sha256: 1404fd22f4166af6f433df97bb3dbe1509d01beaf3566fa41d59fca03080fc70

Contents?: true

Size: 576 Bytes

Versions: 17

Compression:

Stored size: 576 Bytes

Contents

class RestModel
  module Serialization
    class DateTime
      def self.serialize(value)
        ::DateTime.parse value
      rescue
        raise SerializationError, "value '#{value}' is an invalid date time"
      end

      def self.desserialize(value)
        date_time = value.kind_of?(::DateTime) ? value : ::DateTime.parse(value)
        format = RestModel::Configuration.date_time_format
        format ? date_time.strftime(format) : date_time.to_s
      rescue
        raise SerializationError, "value '#{value}' is an invalid date time"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
rest_model-0.2.1 lib/rest_model/serialization/date_time.rb
rest_model-0.2.0 lib/rest_model/serialization/date_time.rb
rest_model-0.1.24 lib/rest_model/serialization/date_time.rb
rest_model-0.1.23 lib/rest_model/serialization/date_time.rb
rest_model-0.1.22 lib/rest_model/serialization/date_time.rb
rest_model-0.1.21 lib/rest_model/serialization/date_time.rb
rest_model-0.1.20 lib/rest_model/serialization/date_time.rb
rest_model-0.1.19 lib/rest_model/serialization/date_time.rb
rest_model-0.1.18 lib/rest_model/serialization/date_time.rb
rest_model-0.1.17 lib/rest_model/serialization/date_time.rb
rest_model-0.1.16 lib/rest_model/serialization/date_time.rb
rest_model-0.1.15 lib/rest_model/serialization/date_time.rb
rest_model-0.1.14 lib/rest_model/serialization/date_time.rb
rest_model-0.1.13 lib/rest_model/serialization/date_time.rb
rest_model-0.1.12 lib/rest_model/serialization/date_time.rb
rest_model-0.1.11 lib/rest_model/serialization/date_time.rb
rest_model-0.1.10 lib/rest_model/serialization/date_time.rb