@@ -286,35 +286,30 @@ end
286286 * @return succeeds or not.
287287]]
288288function Policy :removePolicies (sec , ptype , rules )
289- local size = # self .model [sec ][ptype ].policy
290- for _ , rule in pairs (rules ) do
291- for k , v in pairs (self .model [sec ][ptype ].policy ) do
292- if Util .arrayEquals (rule , v ) then
293- table.remove (self .model [sec ][ptype ].policy , k )
294- break
295- end
296- end
297- end
298-
299- if size > # self .model [sec ][ptype ].policy then
300- return true
301- else
302- return false
303- end
289+ return # self :removePoliciesWithEffected (sec , ptype , rules )~= 0
304290end
305291
306292--[[
307- * removeFilteredPolicyReturnsEffects removes policy rules based on field filters from the model .
293+ * removePoliciesWithEffected removes policy rules from the model, and returns effected rules .
308294 *
309295 * @param sec the section, "p" or "g".
310296 * @param ptype the policy type, "p", "p2", .. or "g", "g2", ..
311- * @param fieldIndex the policy rule's start index to be matched.
312- * @param ... fieldValues the field values to be matched, value ""
313- * means not to match this field.
314- * @return succeeds(effects.size() > 0) or not.
297+ * @param rules the policy rules.
298+ *
299+ * @return effected.
315300]]
316- function Policy :removeFilteredPolicyReturnsEffects (sec , ptype , fieldIndex , ...)
317- return {}
301+ function Policy :removePoliciesWithEffected (sec , ptype , rules )
302+ local effected = {}
303+ for _ ,rule in pairs (rules ) do
304+ for k , v in pairs (self .model [sec ][ptype ].policy ) do
305+ if Util .arrayEquals (rule , v ) then
306+ table.insert (effected ,rule )
307+ table.remove (self .model [sec ][ptype ].policy , k )
308+ break
309+ end
310+ end
311+ end
312+ return effected
318313end
319314
320315--[[
0 commit comments