MOP

 view release on metacpan or  search on metacpan

lib/MOP/Class.pm  view on Meta::CPAN

package MOP::Class;
# ABSTRACT: A representation of a class

use strict;
use warnings;

use mro  ();
use Carp ();

use MOP::Role;
use MOP::Method;
use MOP::Slot;

use MOP::Internal::Util;

our $VERSION   = '0.14';
our $AUTHORITY = 'cpan:STEVAN';

use parent 'UNIVERSAL::Object::Immutable';

our @DOES; BEGIN { @DOES = 'MOP::Role' }; # to be composed later ...
UNITCHECK {
    # apply them roles  ...
    MOP::Internal::Util::APPLY_ROLES(
        MOP::Role->new( name => __PACKAGE__ ),
        \@DOES,
        to => 'class'
    );
}

# superclasses

sub superclasses {
    my ($self) = @_;
    my $isa = MOP::Internal::Util::GET_GLOB_SLOT( $self->stash, 'ISA', 'ARRAY' );
    return unless $isa;
    return @$isa;
}

sub set_superclasses {
    my ($self, @superclasses) = @_;
    Carp::confess('[ARGS] You must specify at least one superclass')
        if scalar( @superclasses ) == 0;
    MOP::Internal::Util::SET_GLOB_SLOT( $self->stash, 'ISA', \@superclasses );
    return;
}

sub mro {
    my ($self) = @_;
    return mro::get_linear_isa( $self->name );
}

1;

__END__

=pod

=head1 NAME

MOP::Class - A representation of a class

=head1 VERSION

version 0.14

=head1 DESCRIPTION

A class I<does> all the things a role does, with the addition of
inheritance and instance construction.

=head1 CONSTRUCTORS

=over 4

=item C<new( name => $package_name )>

=item C<new( $package_name )>

=item C<new( \%package_stash )>

=back



( run in 1.429 second using v1.01-cache-2.11-cpan-39bf76dae61 )