@@ -213,38 +213,50 @@ def build_exchange(id)
213213
214214 private
215215
216- def everylist_subscribe
217- @_everylist_subscribed ||= begin
218- return if Array ( @ whitelist) . none? && Array ( @blacklist ) . none ?
216+ def blacklist_subscribe
217+ return unless blacklist?
218+ raise ArgumentError , "You can't use blacklist along with whitelist" if whitelist ?
219219
220+ @blacklist_subscribe ||= begin
220221 intercept
221222
222- @page . on ( :request ) do |request , index , total |
223- if @blacklist &.any?
224- if @blacklist . any? { |pattern | request . match? ( pattern ) }
225- request . abort and next
226- else
227- request . continue and next
228- end
229- elsif @whitelist &.any?
230- if @whitelist . any? { |pattern | request . match? ( pattern ) }
231- request . continue and next
232- else
233- request . abort and next
234- end
235- elsif index + 1 < total
236- # There are other callbacks that may handle this request
237- next
223+ @page . on ( :request ) do |request |
224+ if @blacklist . any? { |p | request . match? ( p ) }
225+ request . abort
238226 else
239- # If there are no callbacks then just continue
240227 request . continue
241228 end
242229 end
243230
244231 true
245232 end
246233 end
247- alias whitelist_subscribe everylist_subscribe
248- alias blacklist_subscribe everylist_subscribe
234+
235+ def whitelist_subscribe
236+ return unless whitelist?
237+ raise ArgumentError , "You can't use whitelist along with blacklist" if blacklist?
238+
239+ @whitelist_subscribe ||= begin
240+ intercept
241+
242+ @page . on ( :request ) do |request |
243+ if @whitelist . any? { |p | request . match? ( p ) }
244+ request . continue
245+ else
246+ request . abort
247+ end
248+ end
249+
250+ true
251+ end
252+ end
253+
254+ def blacklist?
255+ Array ( @blacklist ) . any?
256+ end
257+
258+ def whitelist?
259+ Array ( @whitelist ) . any?
260+ end
249261 end
250262end
0 commit comments