Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions jaclang_jaseci/plugin/jaseci.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Jac Language Features."""

from collections import OrderedDict
from contextlib import suppress
from dataclasses import Field, MISSING, fields
from functools import wraps
from os import getenv
Expand Down Expand Up @@ -33,6 +34,7 @@
from ..core.architype import (
Anchor,
Architype,
BaseAnchor,
EdgeArchitype,
GenericEdge,
NodeAnchor,
Expand Down Expand Up @@ -434,3 +436,19 @@ def builder(source: NodeAnchor, target: NodeAnchor) -> EdgeArchitype:
return JacFeatureDefaults.build_edge( # type:ignore[return-value]
is_undirected=is_undirected, conn_type=conn_type, conn_assign=conn_assign
)

@staticmethod
@hookimpl
def get_object(id: str) -> Architype | None:
"""Get object via reference id."""
with suppress(ValueError):
if isinstance(architype := BaseAnchor.ref(id).architype, Architype):
return architype

return None

@staticmethod
@hookimpl
def object_ref(obj: Architype) -> str:
"""Get object reference id."""
return str(obj.__jac__.ref_id)