Skip to content

Migration business rule

mongorunway.domain.migration_business_rule ¤

RuleSequence: typing.TypeAlias = typing.MutableSequence['MigrationBusinessRule'] module-attribute ¤

__all__: typing.Sequence[str] = ('MigrationBusinessRule', 'AbstractMigrationBusinessRule') module-attribute ¤

AbstractMigrationBusinessRule ¤

Bases: MigrationBusinessRule, abc.ABC

Source code in mongorunway\domain\migration_business_rule.py
class AbstractMigrationBusinessRule(MigrationBusinessRule, abc.ABC):
    def __init__(self, depends_on: typing.Sequence[MigrationBusinessRule] = ()) -> None:
        self._depends_on = depends_on

    @property
    def name(self) -> str:
        return self.__class__.__name__

    @property
    def depends_on(self) -> typing.Sequence[MigrationBusinessRule]:
        return self._depends_on

    def is_independent(self) -> bool:
        return not self._depends_on

    def render_broken_rule(self) -> str:
        return f"Business rule {self.name} is broken."

depends_on: typing.Sequence[MigrationBusinessRule] property ¤

name: str property ¤

__init__(depends_on=()) ¤

Source code in mongorunway\domain\migration_business_rule.py
def __init__(self, depends_on: typing.Sequence[MigrationBusinessRule] = ()) -> None:
    self._depends_on = depends_on

is_independent() ¤

Source code in mongorunway\domain\migration_business_rule.py
def is_independent(self) -> bool:
    return not self._depends_on

render_broken_rule() ¤

Source code in mongorunway\domain\migration_business_rule.py
def render_broken_rule(self) -> str:
    return f"Business rule {self.name} is broken."

MigrationBusinessRule ¤

Bases: abc.ABC

Source code in mongorunway\domain\migration_business_rule.py
class MigrationBusinessRule(abc.ABC):
    __slots__ = ()

    @property
    @abc.abstractmethod
    def name(self) -> str:
        ...

    @property
    @abc.abstractmethod
    def depends_on(self) -> typing.Sequence[MigrationBusinessRule]:
        ...

    @abc.abstractmethod
    def is_independent(self) -> bool:
        ...

    @abc.abstractmethod
    def check_is_broken(self, ctx: domain_context.MigrationContext) -> bool:
        ...

    @abc.abstractmethod
    def render_broken_rule(self) -> str:
        ...

__slots__ = () instance-attribute class-attribute ¤

depends_on: typing.Sequence[MigrationBusinessRule] property abstractmethod ¤

name: str property abstractmethod ¤

check_is_broken(ctx) abstractmethod ¤

Source code in mongorunway\domain\migration_business_rule.py
@abc.abstractmethod
def check_is_broken(self, ctx: domain_context.MigrationContext) -> bool:
    ...

is_independent() abstractmethod ¤

Source code in mongorunway\domain\migration_business_rule.py
@abc.abstractmethod
def is_independent(self) -> bool:
    ...

render_broken_rule() abstractmethod ¤

Source code in mongorunway\domain\migration_business_rule.py
@abc.abstractmethod
def render_broken_rule(self) -> str:
    ...