David E. Wheeler

NAME

Class::Meta::Class - Class::Meta class introspection

SYNOPSIS

  # Assuming MyApp::Thingy was generated by Class::Meta.
  my $class = MyApp::Thingy->class;
  my $thingy = MyApp::Thingy->new;

  print "Examining object of class ", $class->package, $/;

  print "\nConstructors:\n";
  for my $ctor ($class->constructors) {
      print "  o ", $ctor->name, $/;
  }

  print "\nAttributes:\n";
  for my $attr ($class->attributes) {
      print "  o ", $attr->name, " => ", $attr->call_get($thingy) $/;
  }

  print "\nMethods:\n";
  for my $meth ($class->methods) {
      print "  o ", $meth->name, $/;
  }

DESCRIPTION

Object of this class describe classes created by Class::Meta. They contain everything you need to know about a class to be able to put objects of that class to good use. In addition to retrieving metadata about the class itself, you can retrieve objects that describe the constructors, attributes, and methods of the class. See Class::Meta|Class::Meta for a fuller description of the utility of the Class::Meta suite of modules.

Class::Meta::Class objects are created by Class::Meta; they are never instantiated directly in client code. To access the class object for a Class::Meta-generated class, simply call its class method.

INTERFACE

Instance Methods

package

  my $pkg = $class->package;

Returns the name of the package that the Class::Meta::Class object describes.

key

  my $key = $class->key;

Returns the key name that uniquely identifies the class across the application. The key name may simply be the same as the package name.

name

  my $name = $class->name;

Returns the name of the the class. This should generally be a descriptive name, rather than a package name.

desc

  my $desc = $class->desc;

Returns a description of the class.

is_a

  if ($class->is_a('MyApp::Base')) {
      print "All your base are belong to us\n";
  }

This method returns true if the object or package name passed as an argument is an instance of the class described by the Class::Meta::Class object or one of its subclasses. Functionally equivalent to $class->package->isa($pkg), but more efficient.

constructors

  my @constructors = $class->constructors;
  my $ctor = $class->constructors($ctor_name);
  @constructors = $class->constructors(@ctor_names);

Provides access to the Class::Meta::Constructor objects that describe the constructors for the class. When called with no arguments, it returns all of the constructor objects. When called with a single argument, it returns the constructor object for the constructor with the specified name. When called with a list of arguments, returns all of the constructor objects with the specified names.

attributes

  my @attributes = $class->attributes;
  my $attr = $class->attributes($attr_name);
  @attributes = $class->attributes(@attr_names);

Provides access to the Class::Meta::Attribute objects that describe the attributes for the class. When called with no arguments, it returns all of the attribute objects. When called with a single argument, it returns the attribute object for the attribute with the specified name. When called with a list of arguments, returns all of the attribute objects with the specified names.

methods

  my @methods = $class->methods;
  my $meth = $class->methods($meth_name);
  @methods = $class->methods(@meth_names);

Provides access to the Class::Meta::Method objects that describe the methods for the class. When called with no arguments, it returns all of the method objects. When called with a single argument, it returns the method object for the method with the specified name. When called with a list of arguments, returns all of the method objects with the specified names.

DISTRIBUTION INFORMATION

This file was packaged with the Class-Meta-0.14 distribution.

BUGS

Please report all bugs via the CPAN Request Tracker at http://rt.cpan.org/NoAuth/Bugs.html?Dist=Class-Meta.

AUTHOR

David Wheeler <david@kineticode.com>

SEE ALSO

Other classes of interest within the Class::Meta distribution include:

Class::Meta
Class::Meta::Constructor
Class::Meta::Attribute
Class::Meta::Method

COPYRIGHT AND LICENSE

Copyright (c) 2002-2004, David Wheeler. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.