Module: Selenium::WebDriver::BiDi::Serialization::Record::Serializable Private

Defined in:
lib/selenium/webdriver/bidi/serialization/record.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.as_json(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



357
358
359
360
361
362
363
364
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 357

def self.as_json(value)
  case value
  when Serializable then value.as_json
  when ::Array then value.map { |element| as_json(element) }
  when ::Hash then value.transform_values { |element| as_json(element) }
  else value
  end
end

Instance Method Details

#as_jsonObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Omit UNSET fields; emit null only for nullable ones.



367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 367

def as_json(*)
  payload = {}
  self.class.fields.each do |f|
    value = public_send(f.name)
    next if UNSET.equal?(value)
    next if value.nil? && !f.nullable

    value = Serialization.to_wire(value, Protocol.const_get(f.enum)) if f.enum
    payload[f.wire_key] = Serializable.as_json(value)
  end
  merge_extensions!(payload) if self.class.extensible? && !extensions.empty?
  payload
end