Skip to main content

luna.clause

ClauseConfig Objects

@dataclass
class ClauseConfig()

Data structure for configuring clauses in Luna's contract templates.

  • name: The name of the clause.
  • on_init: A boolean indicating if the clause is executed on initialization.
  • description: An optional description of the clause.
  • occurrences: The number of times the clause should execute. Can be an int, a callable returning an int, or a Valuable int.
  • on: The trigger for the clause execution, can be Event, ClauseExecuted, or Every.
  • args: List of argument names that the clause function takes.

clause

def clause(on_init: bool = False,
occurrences: int | Callable[[], int] | Valuable[int] | None = None,
description: str | None = None,
on: Union["Event", "ClauseExecuted", "Every", None] = None)

Decorator for defining clauses in Luna's contract templates.

  • on_init: Indicates if the clause should be executed on initialization.
  • occurrences: Specifies the number of times the clause should execute.
  • description: Provides an optional description of the clause.
  • on: Defines the trigger for the clause execution.

is_clause

def is_clause(obj)

Utility function to identify if an object is a Luna clause.

  • obj: The object to be checked.
  • Returns: True if the object is a clause, False otherwise.