Rules / Types, classes & roles / metamodel

Metamodel::Trusting Reference

Metaobject that supports trust relations between types

What it is #

Position in the hierarchy #

Inherits from
Does
Consumed byMetamodel::ClassHOW

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method add_trustee #

method add_trustee($type, Mu $trustee)

Trust $trustee.

method trusts #

method trusts($type --> List)

Returns List.

Returns a list of types that the invocant trusts.

method is_trusted #

method is_trusted($type, $claimant)

Returns 1 if $type trusts $claimant, and 0 otherwise. Types always trust themselves.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

5 no-output

role Metamodel::Trusting is SuperClass { ... }

Not executed: the documentation states no expected output for this example.

class A {
    my class B {
        trusts A;   # that's where Metamodel::Trusting comes in
        method !private_method() {
            say "Private method in B";
        }
    }
    method build-and-poke {
        # call a private method from B
        # disallowed if A doesn't trust B
        B.new()!B::private_method();
    }
};

Not executed: the documentation states no expected output for this example.

A.build-and-poke;   # Private method in B

Not executed: the documentation states no expected output for this example.

class A {
BEGIN A.^add_trustee(B);
# same as 'trusts B';
}

Not executed: the documentation states no expected output for this example.

class A { trusts Int; };
say .^name for A.^trusts;       # Int

Not executed: the documentation states no expected output for this example.