optimize war provider ruby code