NAME

InterMine::Model::ClassDescriptor - represents a class in an InterMine model

SYNOPSIS

 use InterMine::Model::ClassDescriptor;

 ...
 my $cd = InterMine::Model::ClassDescriptor->create(
            "Gene" => (
                model => $model,
                parents => ["BioEntity"]
            )
        );

DESCRIPTION

Objects of this class contain the metadata that describes a class in an InterMine model. Each class has a name, parent classes/interfaces and any number of attributes, references and collections.

InterMine class descriptors are sub classes of Moose::Meta::Class, and thus Class::MOP::Class. Please refer to these packages for further documentation.

CLASS METHODS

create( $name | $name, %attributes | $name, \%attributes | \%attributes )

The class constructor inherited from Moose::Meta::Class. Creates a new ClassDescriptor metaclass.

  my $cd = InterMine::Model::ClassDescriptor->create(
       "Gene" => (
           model => $model,
           parents => ["BioEntity"]
       )
  );

Params: =over 4 =item model - the InterMine::Model that this class is a part of =item name - the class name =item parents - a list of the classes and interfaces that this classes extends =back

In most normal use cases, the typical user should NOT need to call this method. It is used internally when parsing the model to build up the list of classes.

INSTANCE ATTRIBUTES

name | package

  • unqualified_name

    returns the (unqualified) name of the class this class descriptor represents.

      $gene_meta->unqualified_name
      # "Gene"
  • package

    This is the attribute inherited from Moose::Meta::Class, and returns the full qualified class name that perl refers to the class internally as.

      $gene_meta->name
      # InterMine::genomic::FlyMine::Gene

own_fields

Fields that belong to this class directly.

add_own_field($field)

Add a field to the list

get_own_fields

Get the full list of fields declared in this class.

own_attributes

Return the fields that are instances of InterMine::Model::Attribute. This is not to be confused with Class::MOP's get_all_attributes.

own_references

Return all the fields that are instances of InterMine::Model::Reference, but not the subclass InterMine::Model::Collection.

own_collections

Return all the fields that are instances of InterMine::Model::Collection.

fieldhash

The map of fields for this class, including inherited fields. It has the following accessors:

set_field($name, $field)

Set a field in the map

get_field_by_name($name)

Retrieve the named field.

fields

Retrieve all fields as a list

valid_field($name)

Returns true if there is a field of this name

attributes

Return the fields that are instances of InterMine::Model::Attribute. This is not to be confused with Class::MOP's get_all_attributes.

references

Return all the fields that are instances of InterMine::Model::Reference, but not the subclass InterMine::Model::Collection.

collections

Return all the fields that are instances of InterMine::Model::Collection.

parents

The names of the immediate ancestors of this class.

parental_class_descriptors

return a list of the ClassDescriptor objects for the classes/interfaces that this class directly extends

 my @parent_cds = $cd->parental_class_descriptors();

Calling this method retrives the parents from the model and also sets up superclass relationships in Moose. It should not be called until the Model is completely parsed. It is called automatically once the model has been parsed.

INSTANCE METHODS

new_object

The instantiation method inherited from Moose::Meta::Class. You should not normally need to use this directly. Instead call the make_new method in InterMine::Model.

get_ancestors

The full inheritance list, including all ancestors in the model.

add_field(FieldDescriptor $field, Bool own)

Add a field to the class. If there is already a field of the same name, it will not be added twice. Setting the boolean flag "own" marks this field as originating in this class

See also: InterMine::Model->_fix_class_descriptors

sub_class_of

Returns true if and only if this class is a sub-class of the given class or is the same class

 if ($cld->sub_class_of($other_cld)) { ... }

superclass_of($other)

Returns true if this class is a superclass of the other one, or if it is the same class.

to_string

The stringification of a class-descriptor. By default, it stringifies to its unqualified_name.

to_xml

Returns a string containing an XML representation of the descriptor

SEE ALSO

AUTHOR

FlyMine <support@flymine.org>

BUGS

Please report any bugs or feature requests to support@flymine.org.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc InterMine::Model::ClassDescriptor

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2006,2007,2008,2009 FlyMine, all rights reserved.

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