Class: BiDiGenerate::UnionClass Private
- Inherits:
-
Struct
- Object
- Struct
- BiDiGenerate::UnionClass
- Defined in:
- lib/selenium/webdriver/bidi/support/bidi_generate.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A generated discriminated union (< Serialization::Union, resolved by lexical scope).
nested holds its synthetic variant records (see nest_synthetic). spec_href links to
the union's definition in the live spec (nil when the schema has none). object_only
mirrors the schema's objectOnly signal: when true, a non-Hash payload is rejected
rather than passed through (every arm is an object, so it can match no variant).
scalar_values mirrors the schema's scalarValues signal: the exact literals a bare-scalar
arm admits (input.Origin's "viewport" / "pointer"), so outbound rejects any other scalar.
Instance Attribute Summary collapse
-
#discriminator_wire ⇒ Object
Returns the value of attribute discriminator_wire.
-
#inbound ⇒ Object
Returns the value of attribute inbound.
-
#nested ⇒ Object
Returns the value of attribute nested.
-
#object_only ⇒ Object
Returns the value of attribute object_only.
-
#outbound ⇒ Object
Returns the value of attribute outbound.
-
#ruby_name ⇒ Object
Returns the value of attribute ruby_name.
-
#scalar_values ⇒ Object
Returns the value of attribute scalar_values.
-
#schema_name ⇒ Object
Returns the value of attribute schema_name.
-
#spec_href ⇒ Object
Returns the value of attribute spec_href.
-
#variant_arg_sigs ⇒ Object
Returns the value of attribute variant_arg_sigs.
-
#variants ⇒ Object
Returns the value of attribute variants.
Instance Method Summary collapse
-
#discriminator_decl(indent) ⇒ Object
private
discriminator 'wire', ordiscriminator 'wire', {sym: 'token', …}(wrapped when long) carrying the inbound wire->symbol map for string-tagged variants. - #fallback_variant ⇒ Object private
- #nested_types ⇒ Object private
- #presence_variants ⇒ Object private
-
#rbs_value_type ⇒ Object
private
The union's RBS value type — the concrete types a value of this union can actually be: each variant record, plus any bare-scalar arm (input.Origin's "viewport"/"pointer").
-
#rbs_variant_factories ⇒ Object
private
RBS for variant_factories: the variant record's own typed
newsignature (threaded in as variant_arg_sigs at build time), so a call is checked against the record's fields rather than an opaque splat; the return type pins the concrete variant. - #scalar_values? ⇒ Boolean private
-
#scalar_values_decl ⇒ Object
private
scalar_values 'viewport', 'pointer'— the literals a bare-scalar arm admits. - #union? ⇒ Boolean private
- #value_variants ⇒ Object private
-
#variant_factories ⇒ Object
private
A class-method factory per discriminated variant, so a caller builds the right variant record without naming its class or repeating the discriminator:
ExtensionData.path(path: '/x')returnsExtensionPath.new(path: '/x').
Instance Attribute Details
#discriminator_wire ⇒ Object
Returns the value of attribute discriminator_wire
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def discriminator_wire @discriminator_wire end |
#inbound ⇒ Object
Returns the value of attribute inbound
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def inbound @inbound end |
#nested ⇒ Object
Returns the value of attribute nested
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def nested @nested end |
#object_only ⇒ Object
Returns the value of attribute object_only
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def object_only @object_only end |
#outbound ⇒ Object
Returns the value of attribute outbound
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def outbound @outbound end |
#ruby_name ⇒ Object
Returns the value of attribute ruby_name
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def ruby_name @ruby_name end |
#scalar_values ⇒ Object
Returns the value of attribute scalar_values
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def scalar_values @scalar_values end |
#schema_name ⇒ Object
Returns the value of attribute schema_name
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def schema_name @schema_name end |
#spec_href ⇒ Object
Returns the value of attribute spec_href
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def spec_href @spec_href end |
#variant_arg_sigs ⇒ Object
Returns the value of attribute variant_arg_sigs
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def variant_arg_sigs @variant_arg_sigs end |
#variants ⇒ Object
Returns the value of attribute variants
461 462 463 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 461 def variants @variants end |
Instance Method Details
#discriminator_decl(indent) ⇒ 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.
discriminator 'wire', or discriminator 'wire', {sym: 'token', …} (wrapped when
long) carrying the inbound wire->symbol map for string-tagged variants.
505 506 507 508 509 510 511 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 505 def discriminator_decl(indent) pairs = value_variants.filter_map(&:discriminator_pair) head = "discriminator '#{discriminator_wire}'" return head if pairs.empty? BiDiGenerate.wrap_call("#{head}, ", pairs, indent, open: '{', close: '}') end |
#fallback_variant ⇒ 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.
467 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 467 def fallback_variant = variants.find { |v| v.mode == :fallback } |
#nested_types ⇒ 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.
468 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 468 def nested_types = nested || [] |
#presence_variants ⇒ 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.
466 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 466 def presence_variants = variants.select { |v| v.mode == :presence } |
#rbs_value_type ⇒ 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.
The union's RBS value type — the concrete types a value of this union can actually be: each variant record, plus any bare-scalar arm (input.Origin's "viewport"/"pointer"). The union class itself has no instances, so this alias (not the class) is what a field, param, or result of the union is typed to, letting a variant pass where the union is expected.
496 497 498 499 500 501 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 496 def rbs_value_type refs = (value_variants + presence_variants + [fallback_variant].compact).map(&:ref).uniq parts = refs.map { |ref| "::Selenium::WebDriver::BiDi::Protocol::#{ref}" } parts += Array(scalar_values).map { |value| value.is_a?(::String) ? value.inspect : value.to_s } parts.empty? ? 'untyped' : parts.join(' | ') end |
#rbs_variant_factories ⇒ 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.
RBS for variant_factories: the variant record's own typed new signature (threaded in
as variant_arg_sigs at build time), so a call is checked against the record's fields
rather than an opaque splat; the return type pins the concrete variant.
484 485 486 487 488 489 490 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 484 def rbs_variant_factories value_variants.map do |variant| args = (variant_arg_sigs || {})[BiDiGenerate.enum_key(variant.value)] || '**untyped' "def self.#{BiDiGenerate.enum_key(variant.value)}: (#{args}) " \ "-> ::Selenium::WebDriver::BiDi::Protocol::#{variant.ref}" end end |
#scalar_values? ⇒ Boolean
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.
513 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 513 def scalar_values? = !(scalar_values.nil? || scalar_values.empty?) |
#scalar_values_decl ⇒ 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.
scalar_values 'viewport', 'pointer' — the literals a bare-scalar arm admits.
516 517 518 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 516 def scalar_values_decl "scalar_values #{scalar_values.map { |v| BiDiGenerate.ruby_literal(v) }.join(', ')}" end |
#union? ⇒ Boolean
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.
464 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 464 def union? = true |
#value_variants ⇒ 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.
465 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 465 def value_variants = variants.select { |v| v.mode == :value } |
#variant_factories ⇒ 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.
A class-method factory per discriminated variant, so a caller builds the right
variant record without naming its class or repeating the discriminator:
ExtensionData.path(path: '/x') returns ExtensionPath.new(path: '/x'). The method
name is the variant's discriminator symbol; every value variant's ref is a record, so
.new is always defined. Presence/fallback arms are omitted (no single tag to name).
475 476 477 478 479 |
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 475 def variant_factories value_variants.map do |variant| "def self.#{BiDiGenerate.enum_key(variant.value)}(**) = #{variant.ref}.new(**)" end end |