class Capybara::Playwright::DialogEventHandler
LILO event handler
Attributes
default_handler[W]
Public Class Methods
new()
click to toggle source
# File lib/capybara/playwright/dialog_event_handler.rb, line 20 def initialize @handlers = [] @mutex = Mutex.new end
Public Instance Methods
add_handler(callable)
click to toggle source
# File lib/capybara/playwright/dialog_event_handler.rb, line 27 def add_handler(callable) item = Item.new(callable) @mutex.synchronize { @handlers << item } item.id end
handle_dialog(dialog)
click to toggle source
# File lib/capybara/playwright/dialog_event_handler.rb, line 50 def handle_dialog(dialog) handler = @mutex.synchronize { @handlers.pop || @default_handler } handler&.call(dialog) end
remove_handler(id)
click to toggle source
# File lib/capybara/playwright/dialog_event_handler.rb, line 35 def remove_handler(id) @mutex.synchronize { @handlers.reject! { |item| item.id == id } } end
with_handler(callable, &block)
click to toggle source
# File lib/capybara/playwright/dialog_event_handler.rb, line 41 def with_handler(callable, &block) id = add_handler(callable) begin block.call ensure remove_handler(id) end end