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.



198
199
200
201
202
203
204
205
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 198

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.



208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 208

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
  payload.merge!(extensions) if self.class.extensible? && !extensions.empty?
  payload
end