role Metamodel::AttributeContainer

Metaobject that can hold attributes
role Metamodel::AttributeContainer {}

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

Classes, roles and grammars can have attributes. Storage and introspection of attributes is implemented by this role.

Methods

method add_attribute

method add_attribute($obj, $attribute)

Adds an attribute. $attribute must be an object that supports the methods name, type and package, which are called without arguments. It can for example be of type Attribute.

method attributes

method attributes($obj)

Returns a list of attributes. For most Raku types, these will be objects of type Attribute.

method set_rw

method set_rw($obj)

Marks a type whose attributes default to having a write accessor. For example in

class Point is rw {
        has $.x;
        has $.y;
    }

The is rw trait on the class calls the set_rw method on the metaclass, making all the attributes implicitly writable, so that you can write;

my $p = Point.new(x => 1, y => 2);
$p.x = 42;

method rw

method rw($obj)

Returns a true value if method set_rw has been called on this object, that is, if new public attributes are writable by default.

See Also

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::Trusting

Metaobject that supports trust relations between types

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.