Class: Jsii::Object
- Inherits:
-
Object
- Object
- Jsii::Object
- Extended by:
- FqnExtension, Registry, StaticConstants
- Includes:
- DynamicInvocation, KernelForwarding, Overrides
- Defined in:
- jsii/object.rb,
jsii/object/registry.rb,
jsii/object/overrides.rb,
jsii/object/kernel_forwarding.rb,
jsii/object/dynamic_invocation.rb
Overview
Base class for all Ruby proxy classes that map to JSII-managed objects.
Defined Under Namespace
Modules: DynamicInvocation, KernelForwarding, Overrides, Registry
Constant Summary
Constants included from Registry
Instance Attribute Summary collapse
-
#jsii_ref ⇒ String
readonly
The
$jsii.byrefhandle for this proxied instance.
Attributes included from FqnExtension
Instance Method Summary collapse
-
#initialize(*args) {|instance| ... } ⇒ Jsii::Object
constructor
Allocate the corresponding object inside the JSII sidecar and store its ref locally.
-
#jsii_interfaces ⇒ Array<String>
The set of JSII interface FQNs this Ruby instance is declared to implement, gathered from every module in its ancestor chain that carries a
jsii_fqn. -
#jsii_serialize ⇒ Hash{String=>Object}
Encodes this proxy as a
$jsii.byrefwire envelope. -
#ruby_class ⇒ Class
Returns the true class of
self, bypassing any user-defined#classoverride (the JSII method-missing path otherwise dispatchesclassover the wire when a remote member happens to be namedclass).
Methods included from Registry
autoload_paths, find_by_ref, find_class_by_fqn, from_jsii_ref, jsii_deserialize, jsii_fqn, objects, register_autoload, register_instance, register_jsii_fqn, registered_class?, registered_class_counts, registry
Methods included from StaticConstants
Methods included from DynamicInvocation
#method_missing, #respond_to_missing?
Methods included from Overrides
Methods included from KernelForwarding
#jsii_async_call_method, #jsii_call_method, #jsii_get_property, #jsii_set_property
Constructor Details
#initialize(*args) {|instance| ... } ⇒ Jsii::Object
Allocate the corresponding object inside the JSII sidecar and store its
ref locally. Subclasses do NOT typically override this — the pacmak
generator emits a thin initialize(arg1, arg2, ...) that forwards via
super, ultimately landing here.
50 51 52 53 54 55 56 57 58 59 |
# File 'jsii/object.rb', line 50 def initialize(*args) # Ask the singleton to create the remote object and store its reference ID @jsii_ref = Jsii::Kernel.instance.create_object(ruby_class.jsii_fqn, args, overrides: jsii_overrides, interfaces: jsii_interfaces, instance: self) ruby_class.register_instance(self) yield self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Jsii::Object::DynamicInvocation
Instance Attribute Details
#jsii_ref ⇒ String (readonly)
Returns the $jsii.byref handle for this proxied instance.
28 29 30 |
# File 'jsii/object.rb', line 28 def jsii_ref @jsii_ref end |
Instance Method Details
#jsii_interfaces ⇒ Array<String>
The set of JSII interface FQNs this Ruby instance is declared to
implement, gathered from every module in its ancestor chain that
carries a jsii_fqn.
66 67 68 69 70 71 72 |
# File 'jsii/object.rb', line 66 def jsii_interfaces # Find all included modules that have a jsii_fqn singleton_class.ancestors .select { |a| a.is_a?(Module) && !a.is_a?(Class) && a.respond_to?(:jsii_fqn) && a.jsii_fqn } .map(&:jsii_fqn) .uniq end |
#jsii_serialize ⇒ Hash{String=>Object}
Encodes this proxy as a $jsii.byref wire envelope.
33 34 35 36 37 38 39 |
# File 'jsii/object.rb', line 33 def jsii_serialize res = { '$jsii.byref' => jsii_ref } if (interfaces = jsii_interfaces) && !interfaces.empty? res['$jsii.interfaces'] = interfaces end res end |
#ruby_class ⇒ Class
Returns the true class of self, bypassing any user-defined #class
override (the JSII method-missing path otherwise dispatches class
over the wire when a remote member happens to be named class).
79 80 81 |
# File 'jsii/object.rb', line 79 def ruby_class ::Object.instance_method(:class).bind(self).call end |