You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: interval.rb
    path of file: ./repos/torque-postgresql/lib/torque/postgresql/adapter/oid
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Torque
  module PostgreSQL
    module Adapter
      module OID
        class Interval < ActiveModel::Type::Value

          CAST_PARTS = [:years, :mon
    
          def cast(value)
            return if value.blank?
            case value
            when ::String then deserialize(value)
            when ::ActiveSupport::Duration then value
            when ::Numeric
              parts = CAST_PARTS.map do |part|
                rest, value = value.divmod(1.send(part))
                rest == 0 ? nil : [part, rest]
              end
              parts_to_duration(parts.compact)
            when ::Array
              value.compact!
              parts = CAST_PARTS.drop(6 - value.size).zip(value).to_h
              parts_to_duration(parts)
            when ::Hash
              parts_to_duration(value)
            else
              value
            end