Class: Playwright::RouteHandlerEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/playwright/route_handler_entry.rb

Instance Method Summary collapse

Constructor Details

#initialize(url, handler) ⇒ RouteHandlerEntry

Returns a new instance of RouteHandlerEntry.

Parameters:

  • url (String)
  • handler (Proc)


5
6
7
8
9
# File 'lib/playwright/route_handler_entry.rb', line 5

def initialize(url, handler)
  @url_value = url
  @url_matcher = UrlMatcher.new(url)
  @handler = handler
end

Instance Method Details

#handle(route, request) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/playwright/route_handler_entry.rb', line 11

def handle(route, request)
  if url_match?(request.url)
    @handler.call(route, request)
    true
  else
    false
  end
end

#same_value?(url:, handler: nil) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
# File 'lib/playwright/route_handler_entry.rb', line 20

def same_value?(url:, handler: nil)
  if handler
    @url_value == url && @handler == handler
  else
    @url_value == url
  end
end