role Metamodel::Trusting

Metaobject that supports trust relations between types
role Metamodel::Trusting is SuperClass { ... }

Warning: this role is part of the Rakudo implementation, and is not a part of the language specification.

Normally, code in a class or role can only access its own private methods. If another type declares that it trusts that first class, then access to private methods of that second type is possible. Metamodel::Trusting implements that aspect of the Raku object system.

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();
        }
    };
A.build-and-poke;   # Private method in B

Methods

method add_trustee

method add_trustee($type, Mu $trustee)

Trust $trustee.

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

method trusts

method trusts($type --> List)

Returns a list of types that the invocant trusts.

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

method is_trusted

method is_trusted($type, $claimant)

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

See Also

role Metamodel::AttributeContainer

Metaobject that can hold attributes

role Metamodel::C3MRO

Metaobject that supports the C3 method resolution order

role Metamodel::Documenting

Metarole for documenting types.

role Metamodel::Finalization

Metaobject supporting object finalization

role Metamodel::MethodContainer

Metaobject that supports storing and introspecting methods

role Metamodel::Mixins

Metaobject for generating mixins

role Metamodel::MROBasedMethodDispatch

Metaobject that supports resolving inherited methods

role Metamodel::MultipleInheritance

Metaobject that supports multiple inheritance

role Metamodel::Naming

Metaobject that supports named types

role Metamodel::ParametricRoleGroupHOW

Represents a group of roles with different parameterizations

role Metamodel::ParametricRoleHOW

Represents a non-instantiated, parameterized, role.

role Metamodel::PrivateMethodContainer

Metaobject that supports private methods

role Metamodel::RoleContainer

Metaobject that supports holding/containing roles

role Metamodel::RolePunning

Metaobject that supports punning of roles.

role Metamodel::Stashing

Metarole for type stashes

role Metamodel::Versioning

Metaobjects that support versioning

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.