lib/catissue/domain/storage_container.rb
def add_to_new_subcontainer(storable)
      # the subcontainers in column, row sort order
      scs = subcontainers.sort { |sc1, sc2| sc1.position.coordinate <=> sc2.position.coordinate }
      logger.debug { "Looking for a #{self} subcontainer #{scs} to place a new #{storable.qp} container..." } unless scs.empty?
      # The first subcontainer that can hold the new subcontainer is preferred.
      sc = scs.detect { |sc| sc.add_to_new_subcontainer(storable) if StorageContainer === sc }
      if sc then
        logger.debug { "#{self} subcontainer #{sc} stored #{storable.qp}." }
        self
      elsif not full? then
        logger.debug { "Creating a subcontainer in #{self} of type #{storage_type} to hold #{storable.qp}..." }
        create_subcontainer_for(storable)
      end
    end
def add_to_new_subcontainer(storable)
      # the subcontainers in column, row sort order
      scs = subcontainers.sort { |sc1, sc2| sc1.position.coordinate <=> sc2.position.coordinate }
      logger.debug { "Looking for a #{self} subcontainer #{scs} to place a new #{storable.qp} container..." } unless scs.empty?
      # The first subcontainer that can hold the new subcontainer is preferred.
      sc = scs.detect { |sc| sc.add_to_new_subcontainer(storable) if StorageContainer === sc }
      if sc then
        logger.debug { "#{self} subcontainer #{sc} stored #{storable.qp}." }
        self
      elsif not full? then
        logger.debug { "Creating a subcontainer in #{self} of type #{storage_type} to hold #{storable.qp}..." }
        create_subcontainer_for(storable)
      end
    end
Creates a subcontainer which holds the given storable. Creates nested subcontainers as necessary.

   @param @storable (see #add)
 @return [StorageContainer, nil] self if a subcontainer was created, nil otherwise