Class: Kobako::Extension

Inherits:
Data
  • Object
show all
Defined in:
lib/kobako/extension.rb,
sig/kobako/extension.rbs

Overview

Kobako::Extension — a guest idiom paired with an optional host backend, installed on a Sandbox via Sandbox#install. It composes the existing #preload (the guest source) and #bind (the backend) verbs into one setup unit, so guest code sees a native-style constant whose pure methods run in-guest and whose privileged methods dispatch to the backend.

The four readers form the contract #install duck-types on:

* +name+ — a Symbol matching +/\A[A-Z]\w*\z/+, the preloaded snippet's
canonical backtrace name and the +depends_on+ match key. Independent
of any bound path.
* +source+ — the mruby idiom as a String; always present, since an
Extension always carries a guest idiom. A host object with no idiom
is bound with +#bind+ directly.
* +backend+ — an +Extension::Backend+ or +nil+ for a pure-guest
Extension.
* +depends_on+ — Symbol names of Extensions that must also be
installed, checked for presence at the first invocation.

Kobako::Extension is the bundled value type; any object exposing the four readers is equally valid, so a Host App or gem may supply its own.

Defined Under Namespace

Classes: Backend

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, source:, backend: nil, depends_on: []) ⇒ Extension

backend and depends_on default to absent so the common pure-idiom and single-backend shapes stay terse.

Parameters:

  • name: (Symbol)
  • source: (String)
  • backend: (Kobako::Extension::Backend, nil) (defaults to: nil)
  • depends_on: (Array[Symbol]) (defaults to: [])


45
46
47
# File 'lib/kobako/extension.rb', line 45

def initialize(name:, source:, backend: nil, depends_on: [])
  super
end

Instance Attribute Details

#backendKobako::Extension::Backend? (readonly)

Returns the value of attribute backend.

Returns:



5
6
7
# File 'sig/kobako/extension.rbs', line 5

def backend
  @backend
end

#depends_onArray[Symbol] (readonly)

Returns the value of attribute depends_on.

Returns:

  • (Array[Symbol])


6
7
8
# File 'sig/kobako/extension.rbs', line 6

def depends_on
  @depends_on
end

#nameSymbol (readonly)

Returns the value of attribute name.

Returns:

  • (Symbol)


3
4
5
# File 'sig/kobako/extension.rbs', line 3

def name
  @name
end

#sourceString (readonly)

Returns the value of attribute source.

Returns:

  • (String)


4
5
6
# File 'sig/kobako/extension.rbs', line 4

def source
  @source
end

Class Method Details

.newKobako::Extension

Parameters:

Returns:



8
# File 'sig/kobako/extension.rbs', line 8

def self.new: (name: Symbol, source: String, ?backend: Kobako::Extension::Backend?, ?depends_on: Array[Symbol]) -> Kobako::Extension