Class: Kobako::Extension::Backend
- Inherits:
-
Data
- Object
- Data
- Kobako::Extension::Backend
- Defined in:
- lib/kobako/extension.rb,
sig/kobako/extension.rbs
Overview
Kobako::Extension::Backend — the host attachment of an Extension,
pairing path (the constant path the backend binds at, single-segment
"File" or nested "MyApp::Store", spelling the guest constant the
idiom routes to) with the source of the bound object, declared by
explicit keyword:
* +object:+ — a static object, fixed for the Sandbox's life.
* +provider:+ — a no-argument callable invoked once per invocation to
yield that invocation's object, so a fresh object backs the path
every invocation. A provider that raises propagates its exception to
the invocation caller and leaves the guest unrun; the next
invocation resolves it afresh.
* neither — a fillable, defaulting to +Kobako::Unresolved+ until the
host supplies the invocation's object.
The kind is chosen by keyword, never inferred from whether the value is
callable, so a static object that is itself callable is expressed
directly with object:. Giving both object: and provider: raises
ArgumentError.
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#path ⇒ String
readonly
Returns the value of attribute path.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path:, object: nil, provider: nil) ⇒ Backend
constructor
A new instance of Backend.
Constructor Details
#initialize(path:, object: nil, provider: nil) ⇒ Backend
Returns a new instance of Backend.
47 48 49 50 51 52 53 54 |
# File 'lib/kobako/extension.rb', line 47 def initialize(path:, object: nil, provider: nil) if !object.nil? && !provider.nil? raise ArgumentError, "Extension::Backend accepts object: or provider:, not both" end super end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
14 15 16 |
# File 'sig/kobako/extension.rbs', line 14 def object @object end |
#path ⇒ String (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'sig/kobako/extension.rbs', line 13 def path @path end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
15 16 17 |
# File 'sig/kobako/extension.rbs', line 15 def provider @provider end |
Class Method Details
.new ⇒ Kobako::Extension::Backend
17 |
# File 'sig/kobako/extension.rbs', line 17
def self.new: (path: String, ?object: untyped, ?provider: untyped) -> Kobako::Extension::Backend
|