---
name: "MooseX::ClassAttribute::Trait::Role"
section: "3pm"
platform: "linux"
package: "libmoosex-classattribute-perl"
version: "0.29-3"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MooseX::ClassAttribute::Trait::Role"
---

# MooseX::ClassAttribute::Trait::Role(3pm)

A trait for roles with class attributes

## NAME

MooseX::ClassAttribute::Trait::Role - A trait for roles with class attributes

## VERSION

version 0.29

## SYNOPSIS

```
  for my $attr ( HasClassAttributes->meta()->get_all_class_attributes() )
  {
      print $attr->name();
  }
```

## DESCRIPTION

This role adds awareness of class attributes to a role metaclass object. It provides a set of introspection methods that largely parallel the existing attribute methods, except they operate on class attributes.

## METHODS

Every method provided by this role has an analogous method in `"Class::MOP::Class"` or `"Moose::Meta::Class"` for regular attributes.

### $meta-\>has\_class\_attribute($name)

### $meta-\>get\_class\_attribute($name)

### $meta-\>get\_class\_attribute\_list()

These methods are exactly like their counterparts in MooseX::ClassAttribute::Trait::Class.

### $meta-\>add\_class\_attribute(...)

This accepts the same options as the Moose::Meta::Attribute `"add_attribute()"` method. However, if an attribute is specified as "required" an error will be thrown.

### $meta-\>remove\_class\_attribute($name)

If the named class attribute exists, it is removed from the role.

## BUGS

See MooseX::ClassAttribute for details.

Bugs may be submitted through the RT bug tracker \<http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-ClassAttribute\> (or bug-moosex-classattribute@rt.cpan.org \<mailto:bug-moosex-classattribute@rt.cpan.org\>).

I am also usually active on IRC as 'drolsky' on `"irc://irc.perl.org"`.

## AUTHOR

Dave Rolsky \<autarch@urth.org\>

## COPYRIGHT AND LICENCE

This software is Copyright (c) 2016 by Dave Rolsky.

This is free software, licensed under:

```
  The Artistic License 2.0 (GPL Compatible)
```
