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

Defined in:
rb/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.



387
388
389
390
391
392
393
394
# File 'rb/lib/selenium/webdriver/bidi/serialization/record.rb', line 387

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_json ⇒ 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.

Omit UNSET fields; emit null only for nullable ones.



397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'rb/lib/selenium/webdriver/bidi/serialization/record.rb', line 397

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