code: def to_h(persist: false)
        {}.tap do |hash|
          (persist ? properties - foreign_objects : properties).each do |property|
            value = self[property]
            if value == false || value.present?
              hash[property] = value
            end
          end
        end
      end
docs: Returns the object as a hash.
  
   @param [Boolean] persist whether the object is being persisted, validated,
     or used as a database selector, in which case foreign objects (hints)
     are excluded
   @return [Hash] the object as a hash