Class: BiDiGenerate::TypeClass Private

Inherits:
Struct
  • Object
show all
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 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 collapse

Instance Method Summary collapse

Instance Attribute Details

#discriminatorObject

Returns the value of attribute discriminator

Returns:

  • (Object)

    the current value of discriminator



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def discriminator
  @discriminator
end

#extensibleObject

Returns the value of attribute extensible

Returns:

  • (Object)

    the current value of extensible



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def extensible
  @extensible
end

#fieldsObject

Returns the value of attribute fields

Returns:

  • (Object)

    the current value of fields



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def fields
  @fields
end

#inboundObject

Returns the value of attribute inbound

Returns:

  • (Object)

    the current value of inbound



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def inbound
  @inbound
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def label
  @label
end

#nestedObject

Returns the value of attribute nested

Returns:

  • (Object)

    the current value of nested



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def nested
  @nested
end

#outboundObject

Returns the value of attribute outbound

Returns:

  • (Object)

    the current value of outbound



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def outbound
  @outbound
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def owner
  @owner
end

#ruby_nameObject

Returns the value of attribute ruby_name

Returns:

  • (Object)

    the current value of ruby_name



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def ruby_name
  @ruby_name
end

#schema_nameObject

Returns the value of attribute schema_name

Returns:

  • (Object)

    the current value of schema_name



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def schema_name
  @schema_name
end

#spec_hrefObject

Returns the value of attribute spec_href

Returns:

  • (Object)

    the current value of spec_href



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def spec_href
  @spec_href
end

#syntheticObject

Returns the value of attribute synthetic

Returns:

  • (Object)

    the current value of synthetic



377
378
379
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 377

def synthetic
  @synthetic
end

Instance Method Details

#define_assignment(name, 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.

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.



396
397
398
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 396

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

#define_entries(entry_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.

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



384
385
386
387
388
389
390
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 384

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_entryObject

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.



400
401
402
403
404
405
406
407
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 400

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_typesObject

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.



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

def nested_types = nested || []

#rbs_new_argsObject

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 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.



425
426
427
428
429
430
431
432
433
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 425

def rbs_new_args
  parts = []
  parts << "?#{discriminator[:ruby_name]}: #{discriminator[:rbs]}" if discriminator
  parts.concat(fields.map(&:rbs_arg))
  # Match the reader type and the extensible Record impl (which calls `merge!`/`empty?` on it),
  # so a type checker rejects a non-Hash before it crashes at serialization.
  parts << '?extensions: Hash[String, untyped]' if extensible
  parts.join(', ')
end

#rbs_readersObject

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.

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.



412
413
414
415
416
417
418
# File 'lib/selenium/webdriver/bidi/support/bidi_generate.rb', line 412

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

#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.

Returns:

  • (Boolean)


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

def union? = false