Class: Playwright::RouteHandler
- Inherits:
-
Object
- Object
- Playwright::RouteHandler
- Defined in:
- lib/playwright/route_handler.rb
Defined Under Namespace
Classes: CountDown, StubCounter
Instance Method Summary collapse
- #handle(route, request) ⇒ Object
-
#initialize(url, base_url, handler, times) ⇒ RouteHandler
constructor
A new instance of RouteHandler.
- #same_value?(url:, handler: nil) ⇒ Boolean
Constructor Details
#initialize(url, base_url, handler, times) ⇒ RouteHandler
Returns a new instance of RouteHandler.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/playwright/route_handler.rb', line 26 def initialize(url, base_url, handler, times) @url_value = url @url_matcher = UrlMatcher.new(url, base_url: base_url) @handler = handler @counter = if times CountDown.new(times) else StubCounter.new end end |
Instance Method Details
#handle(route, request) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/playwright/route_handler.rb', line 38 def handle(route, request) return false unless @counter.handle if @url_matcher.match?(request.url) @handler.call(route, request) true else false end end |
#same_value?(url:, handler: nil) ⇒ Boolean
49 50 51 52 53 54 55 |
# File 'lib/playwright/route_handler.rb', line 49 def same_value?(url:, handler: nil) if handler @url_value == url && @handler == handler else @url_value == url end end |