Class: Kobako::Extension
- Inherits:
-
Data
- Object
- Data
- Kobako::Extension
- 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
-
#backend ⇒ Kobako::Extension::Backend?
readonly
Returns the value of attribute backend.
-
#depends_on ⇒ Array[Symbol]
readonly
Returns the value of attribute depends_on.
-
#name ⇒ Symbol
readonly
Returns the value of attribute name.
-
#source ⇒ String
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, source:, backend: nil, depends_on: []) ⇒ Extension
constructor
backendanddepends_ondefault to absent so the common pure-idiom and single-backend shapes stay terse.
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.
45 46 47 |
# File 'lib/kobako/extension.rb', line 45 def initialize(name:, source:, backend: nil, depends_on: []) super end |
Instance Attribute Details
#backend ⇒ Kobako::Extension::Backend? (readonly)
Returns the value of attribute backend.
5 6 7 |
# File 'sig/kobako/extension.rbs', line 5 def backend @backend end |
#depends_on ⇒ Array[Symbol] (readonly)
Returns the value of attribute depends_on.
6 7 8 |
# File 'sig/kobako/extension.rbs', line 6 def depends_on @depends_on end |
#name ⇒ Symbol (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'sig/kobako/extension.rbs', line 3 def name @name end |
#source ⇒ String (readonly)
Returns the value of attribute source.
4 5 6 |
# File 'sig/kobako/extension.rbs', line 4 def source @source end |
Class Method Details
.new ⇒ Kobako::Extension
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
|