From fe3fb6b974939d0b8f9f0874f73897b7ff45ad27 Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Sat, 6 Jan 2024 12:27:57 +0300 Subject: [PATCH] ref: Preparation for a flatten mode --- lib/ferrum/client.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ferrum/client.rb b/lib/ferrum/client.rb index 37afa112..c909973b 100644 --- a/lib/ferrum/client.rb +++ b/lib/ferrum/client.rb @@ -23,7 +23,10 @@ def initialize(ws_url, options) def command(method, async: false, **params) message = build_message(method, params) + send_message(message, async: async) + end + def send_message(message, async:) if async @ws.send_message(message) true @@ -66,6 +69,10 @@ def inspect "@ws=#{@ws.inspect}>" end + def build_message(method, params) + { method: method, params: params }.merge(id: next_command_id) + end + private def start @@ -83,10 +90,6 @@ def start end end - def build_message(method, params) - { method: method, params: params }.merge(id: next_command_id) - end - def next_command_id @command_id += 1 end