123456789_123456789_123456789_123456789_123456789_

Class: BiDiGenerate::TypeClass Private

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Struct
Instance Chain:
self, Struct
Inherits: Struct
  • Object
Defined in: rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb

Overview

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

Instance Attribute Summary

  • #discriminator rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #extensible rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #fields rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #label rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #nested rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #owner rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #ruby_name rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #schema_name rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #spec_href rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #synthetic rw Internal use only

    A generated immutable value type (a Serialization::Record.define(...) class).

  • #union? ⇒ Boolean readonly Internal use only

Instance Method Summary

  • #define_assignment(name, indent) Internal use only
    Name = {Serialization::Record.define}(...) as one line when it fits within the line limit at the given indent, else wrapped one entry per line — so the emitted source stays inside RuboCop's length limit without a per-file exception.
  • #define_entries(entry_indent) Internal use only

    Keyword arguments for Serialization::Record.define(...): the fixed discriminator member first, then the fields, then the extensible flag.

  • #discriminator_entry Internal use only
  • #nested_types Internal use only
  • #rbs_new_args Internal use only

    The keyword arguments self.new accepts: each constructable field with its value type, plus the optional extensions bag.

  • #rbs_readers Internal use only

    Every Data member gets a typed attr_reader: the baked discriminator (typed to its const), each field (typed when required; UNSET-bearing optionals stay untyped), then the extensible passthrough.

Instance Attribute Details

#discriminator (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#extensible (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#fields (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#label (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#nested (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#owner (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#ruby_name (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#schema_name (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#spec_href (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#synthetic (rw)

A generated immutable value type (a Serialization::Record.define(...) class). discriminator is the baked variant tag wire:, value: or nil; schema_name/synthetic/owner/ nested drive owner-nesting (see nest_synthetic). spec_href links to the type's definition in the live spec (nil when the schema has none, e.g. a synthetic type).

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 283

TypeClass = Struct.new(:ruby_name, :fields, :discriminator, :extensible,
:schema_name, :synthetic, :owner, :label, :nested, :spec_href, keyword_init: true)

#union?Boolean (readonly)

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 285

def union? = false

Instance Method Details

#define_assignment(name, indent)

Name = {Serialization::Record.define}(...) as one line when it fits within the line limit at the given indent, else wrapped one entry per line — so the emitted source stays inside RuboCop's length limit without a per-file exception. Entries render at indent + 2, the indent a long field hash wraps itself against.

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 302

def define_assignment(name, indent)
  BiDiGenerate.wrap_call("#{name} = Serialization::Record.define", define_entries(indent + 2), indent)
end

#define_entries(entry_indent)

Keyword arguments for Serialization::Record.define(...): the fixed discriminator member first, then the fields, then the extensible flag.

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 290

def define_entries(entry_indent)
  entries = []
  entries << discriminator_entry if discriminator
  entries.concat(fields.map { |f| f.spec_entry(entry_indent) })
  entries << 'extensible: true' if extensible
  entries
end

#discriminator_entry

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 306

def discriminator_entry
  literal = BiDiGenerate.ruby_literal(discriminator[:value])
  if discriminator[:wire] == discriminator[:ruby_name].to_s
    "#{discriminator[:ruby_name]}: {fixed: #{literal}}"
  else
    "#{discriminator[:ruby_name]}: {wire_key: '#{discriminator[:wire]}', fixed: #{literal}}"
  end
end

#nested_types

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 286

def nested_types = nested || []

#rbs_new_args

The keyword arguments self.new accepts: each constructable field with its value type, plus the optional extensions bag. The fixed discriminator is baked, so its value is ignored — but the lenient **kwargs constructor still accepts it (and a command method passes it through), so it is advertised as an optional keyword typed to its const.

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 331

def rbs_new_args
  parts = []
  parts << "?#{discriminator[:ruby_name]}: #{discriminator[:rbs]}" if discriminator
  parts.concat(fields.map(&:rbs_arg))
  parts << '?extensions: untyped' if extensible
  parts.join(', ')
end

#rbs_readers

Every Data member gets a typed attr_reader: the baked discriminator (typed to its const), each field (typed when required; UNSET-bearing optionals stay untyped), then the extensible passthrough.

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 318

def rbs_readers
  readers = []
  readers << "#{discriminator[:ruby_name]}: #{discriminator[:rbs]}" if discriminator
  readers.concat(fields.map(&:rbs_reader))
  readers << 'extensions: Hash[String, untyped]' if extensible
  readers
end