Class: Playwright::RouteHandlerEntry

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

Instance Method Summary collapse

Constructor Details

#initialize(url, base_url, handler) ⇒ RouteHandlerEntry

Returns a new instance of RouteHandlerEntry.

Parameters:

  • url (String)
  • base_url (String|nil)
  • handler (Proc)


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

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

Instance Method Details

#handle(route, request) ⇒ Object



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

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

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

Returns:

  • (Boolean)


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

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