Module: Selenium::WebDriver::BiDi::Serialization::Record::Deserializer Private
- Defined in:
- lib/selenium/webdriver/bidi/serialization/record.rb
Overview
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.
Inbound construction: the keyword new (validated) and the wire from_json.
Instance Method Summary collapse
-
#from_json(json_payload) ⇒ Object
private
Inbound: builds from the wire.
- #new(**kwargs) ⇒ Object private
Instance Method Details
#from_json(json_payload) ⇒ 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.
Inbound: builds from the wire. A missing required field raises (in wire_value),
enum tokens are mapped back to symbols and an unrecognized one raises (in read), and
extra keys are captured (extensible) or ignored (closed) — strict on shape, lenient on extras.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 83 def from_json(json_payload) unless json_payload.is_a?(::Hash) raise Error::WebDriverError, "#{name} expected an object on the wire, got #{json_payload.inspect}" end attributes = fields.to_h do |f| [f.name, wire_value(f, json_payload)] end attributes[:extensions] = extra(json_payload) if extensible? construct(**attributes) end |
#new(**kwargs) ⇒ 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.
70 71 72 73 74 75 76 77 78 |
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 70 def new(**kwargs) # Start from what was passed so ::Data's constructor rejects an unknown key, then fill # each field with its value or UNSET (omitted), forcing fixed discriminators. attributes = kwargs.dup fields.each { |f| attributes[f.name] = fixed?(f) ? f.fixed : attributes.fetch(f.name, UNSET) } attributes[:extensions] = kwargs.fetch(:extensions, {}) if extensible? validate_values(attributes) construct(**attributes) end |