def add_to_inverse_collection(newval, accessors, inverse)
      rdr, wtr = accessors
      # the current inverse
      oldval = send(rdr)
      # no-op if no change
      return newval if newval == oldval

      # delete self from the current inverse reference collection
      if oldval then
        coll = oldval.send(inverse)
        coll.delete(self) if coll
      end
      
      # call the writer on this object
      send(wtr, newval)
      
      # add self to the inverse collection
      if newval then
        coll = newval.send(inverse)
        if coll.nil? then
          coll = block_given? ? yield : Array.new
          newval.set_property_value(inverse, coll)
        end
        coll << self
        if oldval then
          logger.debug { "Moved #{qp} from #{rdr} #{oldval.qp} #{inverse} to #{newval.qp}." }
        else
          logger.debug { "Added #{qp} to #{rdr} #{newval.qp} #{inverse}." }
        end
      end
      
      newval
    end
def add_to_inverse_collection(newval, accessors, inverse)
      rdr, wtr = accessors
      # the current inverse
      oldval = send(rdr)
      # no-op if no change
      return newval if newval == oldval

      # delete self from the current inverse reference collection
      if oldval then
        coll = oldval.send(inverse)
        coll.delete(self) if coll
      end
      
      # call the writer on this object
      send(wtr, newval)
      
      # add self to the inverse collection
      if newval then
        coll = newval.send(inverse)
        if coll.nil? then
          coll = block_given? ? yield : Array.new
          newval.set_property_value(inverse, coll)
        end
        coll << self
        if oldval then
          logger.debug { "Moved #{qp} from #{rdr} #{oldval.qp} #{inverse} to #{newval.qp}." }
        else
          logger.debug { "Added #{qp} to #{rdr} #{newval.qp} #{inverse}." }
        end
      end
      
      newval
    end
Sets a collection attribute value in a way which enforces inverse integrity.
 The inverse of the attribute is a collection accessed by calling inverse on newval.

 @param [Resource] newval the new attribute reference value
 @param [(Symbol, Symbol)] accessors the reader and writer to use in setting
   the attribute
 @param [Symbol] inverse the inverse collection attribute to which
   this domain object will be added
 @yield a factory to create a new collection on demand (default is an Array)
 @private