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 is omitted and warned (or
raised in strict mode, in wire_value); enum tokens are mapped back to symbols and an
unrecognized one raises (in read); an undeclared property is captured silently
(extensible) or warned and dropped (closed) — strict on shape, lenient on extras.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 86 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 undeclared = extra(json_payload) if extensible? attributes[:extensions] = undeclared # the spec sanctions these extras; preserve them silently else warn_undeclared(undeclared) unless undeclared.empty? end 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.
72 73 74 75 76 77 78 79 80 |
# File 'lib/selenium/webdriver/bidi/serialization/record.rb', line 72 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 |