GX::Meta::Attribute

Module Version: 0.2000_01

NAME

GX::Meta::Attribute - Attribute metaclass

SYNOPSIS

None.

DESCRIPTION

This module provides the GX::Meta::Attribute class.

METHODS

Constructor

new

Returns a new attribute metaobject.

$attribute = GX::Meta::Attribute->new( %attributes );
Attributes:
  • accessor ( string | HASH reference )

    An accessor definition.

  • accessors ( ARRAY reference )

    A reference to an array of accessor definitions (see above).

  • class ( GX::Meta::Class object ) [ required ]

    The associated class metaobject.

  • constraint ( string | CODE reference )

    A constraint.

  • constraints ( ARRAY reference )

    A reference to an array with constraints (see above).

  • default ( scalar )

    A default value for the attribute slot.

  • initialize ( bool )

    A boolean value indicating whether or not to initialize the attribute on object construction. Defaults to false, which means that the attribute is initialized only on demand, i.e. when it is actually accessed through a generated accessor method.

  • initializer ( string | CODE reference )

    An initializer.

  • isa ( string )

    The attribute type (for example "Scalar", "Array" or "Hash"; see ATTRIBUTE TYPES below) or attribute class (for example "GX::Meta::Attribute::Scalar"). Defaults to "Scalar".

  • name ( string ) [ required ]

    The name of the attribute.

  • preprocessor ( string | CODE reference )

    A preprocessor.

  • private ( bool )

    A boolean value indicating whether the attribute is private or not. Defaults to false.

  • processor ( string | CODE reference )

    A processor.

  • protected ( bool )

    A boolean value indicating whether the attribute is protected or not. Defaults to false.

  • public ( bool )

    A boolean value indicating whether the attribute is public or not. Defaults to true.

  • required ( bool )

    A boolean value indicating whether the attribute is required or not. Defaults to false.

  • slot ( string )

    The name of the attribute slot. Defaults to the name of the attribute.

  • static ( bool )

    A boolean value indicating whether the attribute is a static (class) attribute or not. Defaults to false.

  • sticky ( bool )

    A boolean value indicating whether the attribute is sticky or not. Defaults to false.

  • type ( string )

    The attribute type, for example "Scalar", "Array" or "Hash" (see ATTRIBUTE TYPES below).

Returns:
Exceptions:

Public Methods

accessors

Returns the associated accessor metaobjects.

@accessors = $attribute->accessors;
Returns:

add_accessor

Creates a new accessor metaobject for the attribute and adds it.

$accessor = $attribute->add_accessor( %arguments );
Arguments:
Returns:
Exceptions:

add_preprocessor

Adds a preprocessor.

$attribute->add_preprocessor( $preprocessor );
Arguments:
  • $preprocessor ( string | CODE reference )

    A code reference or method name.

Exceptions:

add_processor

Adds a processor.

$attribute->add_processor( $processor );
Arguments:
  • $processor ( string | CODE reference )

    A code reference or method name.

Exceptions:

add_type_constraint

Adds a type constraint.

$attribute->add_type_constraint( $constraint );
Arguments:
  • $constraint ( string | CODE reference )

    A code reference or method name.

Exceptions:

add_value_constraint

Adds a value constraint.

$attribute->add_value_constraint( $constraint );
Arguments:
  • $constraint ( string | CODE reference )

    A code reference or method name.

Exceptions:

class

Returns the associated class metaobject.

$class = $attribute->class;
Returns:

default_value

Returns the default attribute value.

$default_value = $attribute->default_value;
Returns:
  • $default_value ( scalar )

has_default_value

Returns true if the attribute has a default value, otherwise false.

$result = $attribute->has_default_value;
Returns:
  • $result ( bool )

has_initializer

Returns true if the attribute has an initializer, otherwise false.

$result = $attribute->has_initializer;
Returns:
  • $result ( bool )

initializer

Returns the initializer, or undef if the attribute does not have one.

$initializer = $attribute->initializer;
Returns:
  • $initializer ( string | CODE reference | undef )

install

Installs the attribute.

$attribute->install;
Exceptions:

install_accessors

Installs the accessors.

$attribute->install_accessors;
Exceptions:

is_private

Returns true if the attribute is private, otherwise false.

$result = $attribute->is_private;
Returns:
  • $result ( bool )

is_protected

Returns true if the attribute is protected, otherwise false.

$result = $attribute->is_protected;
Returns:
  • $result ( bool )

is_public

Returns true if the attribute is public, otherwise false.

$result = $attribute->is_public;
Returns:
  • $result ( bool )

is_required

Returns true if the attribute is required, otherwise false.

$result = $attribute->is_required;
Returns:
  • $result ( bool )

is_static

Returns true if the attribute is static, otherwise false.

$result = $attribute->is_static;
Returns:
  • $result ( bool )

is_sticky

Returns true if the attribute is sticky, otherwise false.

$result = $attribute->is_sticky;
Returns:
  • $result ( bool )

name

Returns the name of the attribute.

$name = $attribute->name;
Returns:
  • $name ( string )

preprocessors

Returns the preprocessors.

@preprocessors = $attribute->preprocessors;
Returns:
  • @preprocessors ( strings | CODE references )

processors

Returns the processors.

@processors = $attribute->processors;
Returns:
  • @processors ( strings | CODE references )

quoted_slot_key

Returns the quoted slot key.

$quoted_slot_key = $attribute->quoted_slot_key;
Returns:
  • $quoted_slot_key ( string )

slot_key

Returns the slot key.

$slot_key = $attribute->slot_key;
Returns:
  • $slot_key ( string )

type

Returns a string identifying the attribute type.

$type = $attribute->type;
Returns:
  • $type ( string )

type_constraints

Returns the type constraints.

@constraints = $attribute->type_constraints;
Returns:
  • @constraints ( strings | CODE references )

value_constraints

Returns the value constraints.

@constraints = $attribute->value_constraints;
Returns:
  • @constraints ( strings | CODE references )

SEE ALSO

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 2009-2011 Jörg A. Uzarek.

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.