def create_unit(type, attributes: {})
      "#{self.class.name.split('::').first}::#{type.to_s.camelize}".constantize
        .new(options: unit_options, logger: logger).tap do |unit|
        {src: :source, dst: :destination}.each do |k, v|
          unit.send "#{v}=".to_sym, attributes[k] unless attributes[k].nil?
        end

        UNIT_ATTRIBUTES[type].each do |v|
          unit.send "#{v}=".to_sym, defaults[v] unless defaults[v].nil?
          unit.send "#{v}=".to_sym, attributes[v] unless attributes[v].nil?
        end
      end
    end
def create_unit(type, attributes: {})
      "#{self.class.name.split('::').first}::#{type.to_s.camelize}".constantize
        .new(options: unit_options, logger: logger).tap do |unit|
        {src: :source, dst: :destination}.each do |k, v|
          unit.send "#{v}=".to_sym, attributes[k] unless attributes[k].nil?
        end

        UNIT_ATTRIBUTES[type].each do |v|
          unit.send "#{v}=".to_sym, defaults[v] unless defaults[v].nil?
          unit.send "#{v}=".to_sym, attributes[v] unless attributes[v].nil?
        end
      end
    end
Creates a new unit object for the collection.
 @param type [Symbol] a unit type in {UNIT_TYPES}
 @param attributes [Hash] attributes for the unit from {UNIT_ATTRIBUTES}
 @return [Unit] the unit object of the appropriate subclass