def key_value(attributes)
      attributes ||= self.class.primary_key_attributes
      case attributes.size
      when 0 then nil
      when 1 then send(attributes.first)
      else
        key = attributes.map { |pa| send(pa) || return }
        key unless key.empty?
      end
    end
def key_value(attributes)
      attributes ||= self.class.primary_key_attributes
      case attributes.size
      when 0 then nil
      when 1 then send(attributes.first)
      else
        key = attributes.map { |pa| send(pa) || return }
        key unless key.empty?
      end
    end
Returns the key for the given key attributes as follows:
 * If there are no key attributes, then nil.
 * Otherwise, if any key attribute value is missing, then nil.
 * Otherwise, if the key attributes is a singleton Array, then the key is the
   value of the sole key attribute.
 * Otherwise, the key is an Array of the key attribute values.

 @param [<Symbol>] attributes the key attributes, or nil for the primary key
 @return [Array, Object, nil] the key value or values