2 package Moose::Meta::Role;
8 use Scalar::Util 'blessed';
11 our $VERSION = '0.73_02';
12 $VERSION = eval $VERSION;
13 our $AUTHORITY = 'cpan:STEVAN';
15 use Moose::Meta::Class;
16 use Moose::Meta::Role::Method;
17 use Moose::Meta::Role::Method::Required;
19 use base 'Class::MOP::Module';
21 ## ------------------------------------------------------------------
23 ## I normally don't do this, but I am doing
24 ## a whole bunch of meta-programmin in this
25 ## module, so it just makes sense. For a clearer
26 ## picture of what is going on in the next
27 ## several lines of code, look at the really
28 ## big comment at the end of this file (right
31 ## ------------------------------------------------------------------
33 my $META = __PACKAGE__->meta;
35 ## ------------------------------------------------------------------
39 # since roles are lazy, we hold all the attributes
40 # of the individual role in 'statis' until which
41 # time when it is applied to a class. This means
42 # keeping a lot of things in hash maps, so we are
43 # using a little of that meta-programmin' magic
44 # here an saving lots of extra typin. And since
45 # many of these attributes above require similar
46 # functionality to support them, so we again use
47 # the wonders of meta-programmin' to deliver a
48 # very compact solution to this normally verbose
54 name => 'excluded_roles_map',
55 attr_reader => 'get_excluded_roles_map' ,
57 add => 'add_excluded_roles',
58 get_list => 'get_excluded_roles_list',
59 existence => 'excludes_role',
63 name => 'required_methods',
64 attr_reader => 'get_required_methods_map',
66 add => 'add_required_methods',
67 remove => 'remove_required_methods',
68 get_list => 'get_required_method_list',
69 existence => 'requires_method',
73 name => 'attribute_map',
74 attr_reader => 'get_attribute_map',
76 get => 'get_attribute',
77 get_list => 'get_attribute_list',
78 existence => 'has_attribute',
79 remove => 'remove_attribute',
84 my $attr_reader = $action->{attr_reader};
85 my $methods = $action->{methods};
87 # create the attribute
88 $META->add_attribute($action->{name} => (
89 reader => $attr_reader,
93 # create some helper methods
94 $META->add_method($methods->{add} => sub {
95 my ($self, @values) = @_;
96 $self->$attr_reader->{$_} = undef foreach @values;
97 }) if exists $methods->{add};
99 $META->add_method($methods->{get_list} => sub {
101 keys %{$self->$attr_reader};
102 }) if exists $methods->{get_list};
104 $META->add_method($methods->{get} => sub {
105 my ($self, $name) = @_;
106 $self->$attr_reader->{$name}
107 }) if exists $methods->{get};
109 $META->add_method($methods->{existence} => sub {
110 my ($self, $name) = @_;
111 exists $self->$attr_reader->{$name} ? 1 : 0;
112 }) if exists $methods->{existence};
114 $META->add_method($methods->{remove} => sub {
115 my ($self, @values) = @_;
116 delete $self->$attr_reader->{$_} foreach @values;
117 }) if exists $methods->{remove};
120 ## some things don't always fit, so they go here ...
125 unless ( defined $name && $name ) {
127 Moose->throw_error("You must provide a name for the attribute");
130 if (scalar @_ == 1 && ref($_[0]) eq 'HASH') {
136 $self->get_attribute_map->{$name} = $attr_desc;
140 # sub _clean_up_required_methods {
142 # foreach my $method ($self->get_required_method_list) {
143 # $self->remove_required_methods($method)
144 # if $self->has_method($method);
148 ## ------------------------------------------------------------------
152 # the before/around/after method modifiers are
153 # stored by name, but there can be many methods
154 # then associated with that name. So again we have
155 # lots of similar functionality, so we can do some
156 # meta-programmin' and save some time.
159 foreach my $modifier_type (qw[ before around after ]) {
161 my $attr_reader = "get_${modifier_type}_method_modifiers_map";
163 # create the attribute ...
164 $META->add_attribute("${modifier_type}_method_modifiers" => (
165 reader => $attr_reader,
166 default => sub { {} }
169 # and some helper methods ...
170 $META->add_method("get_${modifier_type}_method_modifiers" => sub {
171 my ($self, $method_name) = @_;
172 #return () unless exists $self->$attr_reader->{$method_name};
173 @{$self->$attr_reader->{$method_name}};
176 $META->add_method("has_${modifier_type}_method_modifiers" => sub {
177 my ($self, $method_name) = @_;
179 # for now we assume that if it exists,..
180 # it has at least one modifier in it
181 (exists $self->$attr_reader->{$method_name}) ? 1 : 0;
184 $META->add_method("add_${modifier_type}_method_modifier" => sub {
185 my ($self, $method_name, $method) = @_;
187 $self->$attr_reader->{$method_name} = []
188 unless exists $self->$attr_reader->{$method_name};
190 my $modifiers = $self->$attr_reader->{$method_name};
193 # check to see that we aren't adding the
194 # same code twice. We err in favor of the
195 # first on here, this may not be as expected
196 foreach my $modifier (@{$modifiers}) {
197 return if $modifier == $method;
200 push @{$modifiers} => $method;
205 ## ------------------------------------------------------------------
206 ## override method mofidiers
208 $META->add_attribute('override_method_modifiers' => (
209 reader => 'get_override_method_modifiers_map',
210 default => sub { {} }
214 # these are a little different because there
215 # can only be one per name, whereas the other
216 # method modifiers can have multiples.
219 sub add_override_method_modifier {
220 my ($self, $method_name, $method) = @_;
221 (!$self->has_method($method_name))
222 || Moose->throw_error("Cannot add an override of method '$method_name' " .
223 "because there is a local version of '$method_name'");
224 $self->get_override_method_modifiers_map->{$method_name} = $method;
227 sub has_override_method_modifier {
228 my ($self, $method_name) = @_;
230 # for now we assume that if it exists,..
231 # it has at least one modifier in it
232 (exists $self->get_override_method_modifiers_map->{$method_name}) ? 1 : 0;
235 sub get_override_method_modifier {
236 my ($self, $method_name) = @_;
237 $self->get_override_method_modifiers_map->{$method_name};
240 ## general list accessor ...
242 sub get_method_modifier_list {
243 my ($self, $modifier_type) = @_;
244 my $accessor = "get_${modifier_type}_method_modifiers_map";
245 keys %{$self->$accessor};
248 sub reset_package_cache_flag { (shift)->{'_package_cache_flag'} = undef }
249 sub update_package_cache_flag {
251 $self->{'_package_cache_flag'} = Class::MOP::check_package_cache_flag($self->name);
256 ## ------------------------------------------------------------------
259 $META->add_attribute('roles' => (
260 reader => 'get_roles',
261 default => sub { [] }
265 my ($self, $role) = @_;
266 (blessed($role) && $role->isa('Moose::Meta::Role'))
267 || Moose->throw_error("Roles must be instances of Moose::Meta::Role");
268 push @{$self->get_roles} => $role;
269 $self->reset_package_cache_flag;
272 sub calculate_all_roles {
278 $_->calculate_all_roles
279 } @{ $self->get_roles });
283 my ($self, $role_name) = @_;
285 || Moose->throw_error("You must supply a role name to look for");
286 # if we are it,.. then return true
287 return 1 if $role_name eq $self->name;
288 # otherwise.. check our children
289 foreach my $role (@{$self->get_roles}) {
290 return 1 if $role->does_role($role_name);
295 ## ------------------------------------------------------------------
298 sub method_metaclass { 'Moose::Meta::Role::Method' }
303 my $current = Class::MOP::check_package_cache_flag($self->name);
305 if (defined $self->{'_package_cache_flag'} && $self->{'_package_cache_flag'} == $current) {
306 return $self->{'methods'} ||= {};
309 $self->{_package_cache_flag} = $current;
311 my $map = $self->{'methods'} ||= {};
313 my $role_name = $self->name;
314 my $method_metaclass = $self->method_metaclass;
316 my $all_code = $self->get_all_package_symbols('CODE');
318 foreach my $symbol (keys %{ $all_code }) {
319 my $code = $all_code->{$symbol};
321 next if exists $map->{$symbol} &&
322 defined $map->{$symbol} &&
323 $map->{$symbol}->body == $code;
325 my ($pkg, $name) = Class::MOP::get_code_info($code);
326 my $meta = Class::MOP::class_of($pkg);
328 if ($meta && $meta->isa('Moose::Meta::Role')) {
329 my $role = $meta->name;
330 next unless $self->does_role($role);
334 # in 5.10 constant.pm the constants show up
335 # as being in the right package, but in pre-5.10
336 # they show up as constant::__ANON__ so we
337 # make an exception here to be sure that things
338 # work as expected in both.
340 unless ($pkg eq 'constant' && $name eq '__ANON__') {
341 next if ($pkg || '') ne $role_name ||
342 (($name || '') ne '__ANON__' && ($pkg || '') ne $role_name);
346 $map->{$symbol} = $method_metaclass->wrap(
348 package_name => $role_name,
357 my ($self, $name) = @_;
358 $self->get_method_map->{$name};
362 my ($self, $name) = @_;
363 exists $self->get_method_map->{$name} ? 1 : 0
366 # FIXME this is copy-pasted from Class::MOP::Class
367 # refactor to inherit from some common base
368 sub wrap_method_body {
369 my ( $self, %args ) = @_;
371 ('CODE' eq ref $args{body})
372 || Moose->throw_error("Your code block must be a CODE reference");
374 $self->method_metaclass->wrap(
375 package_name => $self->name,
381 my ($self, $method_name, $method) = @_;
382 (defined $method_name && $method_name)
383 || Moose->throw_error("You must define a method name");
386 if (blessed($method)) {
387 $body = $method->body;
388 if ($method->package_name ne $self->name) {
389 $method = $method->clone(
390 package_name => $self->name,
392 ) if $method->can('clone');
397 $method = $self->wrap_method_body( body => $body, name => $method_name );
400 $method->attach_to_class($self);
402 $self->get_method_map->{$method_name} = $method;
404 my $full_method_name = ($self->name . '::' . $method_name);
405 $self->add_package_symbol(
406 { sigil => '&', type => 'CODE', name => $method_name },
407 Class::MOP::subname($full_method_name => $body)
410 $self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it
413 sub find_method_by_name { (shift)->get_method(@_) }
415 sub get_method_list {
417 grep { !/^meta$/ } keys %{$self->get_method_map};
421 Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
425 $self->add_method(@_);
428 ## ------------------------------------------------------------------
430 ## ------------------------------------------------------------------
433 my ($self, $other, @args) = @_;
436 || Moose->throw_error("You must pass in an blessed instance");
438 if ($other->isa('Moose::Meta::Role')) {
439 require Moose::Meta::Role::Application::ToRole;
440 return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other);
442 elsif ($other->isa('Moose::Meta::Class')) {
443 require Moose::Meta::Role::Application::ToClass;
444 return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other);
447 require Moose::Meta::Role::Application::ToInstance;
448 return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other);
453 my ($class, @role_specs) = @_;
455 require Moose::Meta::Role::Application::RoleSummation;
456 require Moose::Meta::Role::Composite;
458 my (@roles, %role_params);
459 while (@role_specs) {
460 my ($role, $params) = @{ splice @role_specs, 0, 1 };
461 push @roles => Class::MOP::class_of($role);
462 next unless defined $params;
463 $role_params{$role} = $params;
466 my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
467 Moose::Meta::Role::Application::RoleSummation->new(
468 role_params => \%role_params
475 my ( $role, $package_name, %options ) = @_;
477 $options{package} = $package_name;
479 (ref $options{attributes} eq 'HASH')
480 || confess "You must pass a HASH ref of attributes"
481 if exists $options{attributes};
483 (ref $options{methods} eq 'HASH')
484 || confess "You must pass a HASH ref of methods"
485 if exists $options{methods};
487 my (%initialize_options) = %options;
488 delete @initialize_options{qw(
496 my $meta = $role->initialize( $package_name => %initialize_options );
498 $meta->_instantiate_module( $options{version}, $options{authority} );
501 $meta->add_method('meta' => sub {
502 $role->initialize(ref($_[0]) || $_[0]);
505 if (exists $options{attributes}) {
506 foreach my $attribute_name (keys %{$options{attributes}}) {
507 my $attr = $options{attributes}->{$attribute_name};
508 $meta->add_attribute($attribute_name => $attr);
512 if (exists $options{methods}) {
513 foreach my $method_name (keys %{$options{methods}}) {
514 $meta->add_method($method_name, $options{methods}->{$method_name});
518 Class::MOP::weaken_metaclass($meta->name)
519 if $meta->is_anon_role;
524 # anonymous roles. most of it is copied straight out of Class::MOP::Class.
525 # an intrepid hacker might find great riches if he unifies this code with that
526 # code in Class::MOP::Module or Class::MOP::Package
529 # this should be sufficient, if you have a
530 # use case where it is not, write a test and
532 my $ANON_ROLE_SERIAL = 0;
535 # we need a sufficiently annoying prefix
536 # this should suffice for now, this is
537 # used in a couple of places below, so
538 # need to put it up here for now.
539 my $ANON_ROLE_PREFIX = 'Moose::Meta::Role::__ANON__::SERIAL::';
543 no warnings 'uninitialized';
544 $self->name =~ /^$ANON_ROLE_PREFIX/;
547 sub create_anon_role {
548 my ($role, %options) = @_;
549 my $package_name = $ANON_ROLE_PREFIX . ++$ANON_ROLE_SERIAL;
550 return $role->create($package_name, %options);
554 # this will only get called for
555 # anon-roles, all other calls
556 # are assumed to occur during
557 # global destruction and so don't
558 # really need to be handled explicitly
562 return if Class::MOP::in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
564 no warnings 'uninitialized';
565 return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
567 # XXX: is this necessary for us? I don't understand what it's doing
570 # Moose does a weird thing where it replaces the metaclass for
571 # class when fixing metaclass incompatibility. In that case,
572 # we don't want to clean out the namespace now. We can detect
573 # that because Moose will explicitly update the singleton
574 # cache in Class::MOP.
575 #my $current_meta = Class::MOP::get_metaclass_by_name($self->name);
576 #return if $current_meta ne $self;
578 my ($serial_id) = ($self->name =~ /^$ANON_ROLE_PREFIX(\d+)/);
580 foreach my $key (keys %{$ANON_ROLE_PREFIX . $serial_id}) {
581 delete ${$ANON_ROLE_PREFIX . $serial_id}{$key};
583 delete ${'main::' . $ANON_ROLE_PREFIX}{$serial_id . '::'};
587 #####################################################################
589 ## This is Moose::Meta::Role as defined by Moose (plus the use of
590 ## MooseX::AttributeHelpers module). It is here as a reference to
591 ## make it easier to see what is happening above with all the meta
593 #####################################################################
596 # metaclass => 'Collection::Array',
597 # reader => 'get_roles',
598 # isa => 'ArrayRef[Moose::Meta::Roles]',
599 # default => sub { [] },
601 # 'push' => 'add_role',
605 # has 'excluded_roles_map' => (
606 # metaclass => 'Collection::Hash',
607 # reader => 'get_excluded_roles_map',
608 # isa => 'HashRef[Str]',
610 # # Not exactly set, cause it sets multiple
611 # 'set' => 'add_excluded_roles',
612 # 'keys' => 'get_excluded_roles_list',
613 # 'exists' => 'excludes_role',
617 # has 'attribute_map' => (
618 # metaclass => 'Collection::Hash',
619 # reader => 'get_attribute_map',
620 # isa => 'HashRef[Str]',
622 # # 'set' => 'add_attribute' # has some special crap in it
623 # 'get' => 'get_attribute',
624 # 'keys' => 'get_attribute_list',
625 # 'exists' => 'has_attribute',
626 # # Not exactly delete, cause it sets multiple
627 # 'delete' => 'remove_attribute',
631 # has 'required_methods' => (
632 # metaclass => 'Collection::Hash',
633 # reader => 'get_required_methods_map',
634 # isa => 'HashRef[Str]',
636 # # not exactly set, or delete since it works for multiple
637 # 'set' => 'add_required_methods',
638 # 'delete' => 'remove_required_methods',
639 # 'keys' => 'get_required_method_list',
640 # 'exists' => 'requires_method',
644 # # the before, around and after modifiers are
645 # # HASH keyed by method-name, with ARRAY of
646 # # CODE refs to apply in that order
648 # has 'before_method_modifiers' => (
649 # metaclass => 'Collection::Hash',
650 # reader => 'get_before_method_modifiers_map',
651 # isa => 'HashRef[ArrayRef[CodeRef]]',
653 # 'keys' => 'get_before_method_modifiers',
654 # 'exists' => 'has_before_method_modifiers',
655 # # This actually makes sure there is an
656 # # ARRAY at the given key, and pushed onto
657 # # it. It also checks for duplicates as well
658 # # 'add' => 'add_before_method_modifier'
662 # has 'after_method_modifiers' => (
663 # metaclass => 'Collection::Hash',
664 # reader =>'get_after_method_modifiers_map',
665 # isa => 'HashRef[ArrayRef[CodeRef]]',
667 # 'keys' => 'get_after_method_modifiers',
668 # 'exists' => 'has_after_method_modifiers',
669 # # This actually makes sure there is an
670 # # ARRAY at the given key, and pushed onto
671 # # it. It also checks for duplicates as well
672 # # 'add' => 'add_after_method_modifier'
676 # has 'around_method_modifiers' => (
677 # metaclass => 'Collection::Hash',
678 # reader =>'get_around_method_modifiers_map',
679 # isa => 'HashRef[ArrayRef[CodeRef]]',
681 # 'keys' => 'get_around_method_modifiers',
682 # 'exists' => 'has_around_method_modifiers',
683 # # This actually makes sure there is an
684 # # ARRAY at the given key, and pushed onto
685 # # it. It also checks for duplicates as well
686 # # 'add' => 'add_around_method_modifier'
690 # # override is similar to the other modifiers
691 # # except that it is not an ARRAY of code refs
692 # # but instead just a single name->code mapping
694 # has 'override_method_modifiers' => (
695 # metaclass => 'Collection::Hash',
696 # reader =>'get_override_method_modifiers_map',
697 # isa => 'HashRef[CodeRef]',
699 # 'keys' => 'get_override_method_modifier',
700 # 'exists' => 'has_override_method_modifier',
701 # 'add' => 'add_override_method_modifier', # checks for local method ..
705 #####################################################################
716 Moose::Meta::Role - The Moose Role metaclass
720 This class is a subclass of L<Class::MOP::Module> that provides
721 additional Moose-specific functionality.
723 It's API looks a lot like L<Moose::Meta::Class>, but internally it
724 implements many things differently. This may change in the future.
728 C<Moose::Meta::Role> is a subclass of L<Class::MOP::Module>.
736 =item B<< Moose::Meta::Role->initialize($role_name) >>
738 This method creates a new role object with the provided name.
740 =item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
742 This method accepts a list of array references. Each array reference
743 should contain a role name as its first element. The second element is
744 an optional hash reference. The hash reference can contain C<exclude>
745 and C<alias> keys to control how methods are composed from the role.
747 The return value is a new L<Moose::Meta::Role::Composite> that
748 represents the combined roles.
750 =item B<< Moose::Meta::Role->create($name, %options) >>
752 This method is identical to the L<Moose::Meta::Class> C<create>
755 =item B<< Moose::Meta::Role->create_anon_role >>
757 This method is identical to the L<Moose::Meta::Class>
758 C<create_anon_class> method.
760 =item B<< $metarole->is_anon_role >>
762 Returns true if the role is an anonymous role.
766 =head2 Role application
770 =item B<< $metarole->apply( $thing, @options ) >>
772 This method applies a role to the given C<$thing>. That can be another
773 L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
774 (non-meta) object instance.
776 The options are passed directly to the constructor for the appropriate
777 L<Moose::Meta::Role::Application> subclass.
781 =head2 Roles and other roles
785 =item B<< $metarole->get_roles >>
787 This returns an array reference of roles which this role does. This
788 list may include duplicates.
790 =item B<< $metarole->calculate_all_roles >>
792 This returns a I<unique> list of all roles that this role does, and
793 all the roles that its roles do.
795 =item B<< $metarole->does_role($role_name) >>
797 Given a role I<name>, returns true if this role does the given
800 =item B<< $metarole->add_role($role) >>
802 Given a L<Moose::Meta::Role> object, this adds the role to the list of
803 roles that the role does.
805 =item B<< $metarole->get_excluded_roles_list >>
807 Returns a list of role names which this role excludes.
809 =item B<< $metarole->excludes_role($role_name) >>
811 Given a role I<name>, returns true if this role excludes the named
814 =item B<< $metarole->add_excluded_roles(@role_names) >>
816 Given one or more role names, adds those roles to the list of excluded
823 The methods for dealing with a role's methods are all identical in API
824 and behavior to the same methods in L<Class::MOP::Class>.
828 =item B<< $metarole->method_metaclass >>
830 Returns the method metaclass name for the role. This defaults to
831 L<Moose::Meta::Role::Method>.
833 =item B<< $metarole->get_method($name) >>
835 =item B<< $metarole->has_method($name) >>
837 =item B<< $metarole->add_method( $name, $body ) >>
839 =item B<< $metarole->get_method_list >>
841 =item B<< $metarole->get_method_map >>
843 =item B<< $metarole->find_method_by_name($name) >>
845 These methods are all identical to the methods of the same name in
852 As with methods, the methods for dealing with a role's attribute are
853 all identical in API and behavior to the same methods in
854 L<Class::MOP::Class>.
856 However, attributes stored in this class are I<not> stored as
857 objects. Rather, the attribute definition is stored as a hash
858 reference. When a role is composed into a class, this hash reference
859 is passed directly to the metaclass's C<add_attribute> method.
861 This is quite likely to change in the future.
865 =item B<< $metarole->get_attribute($attribute_name) >>
867 =item B<< $metarole->has_attribute($attribute_name) >>
869 =item B<< $metarole->get_attribute_map >>
871 =item B<< $metarole->get_attribute_list >>
873 =item B<< $metarole->add_attribute($name, %options) >>
875 =item B<< $metarole->remove_attribute($attribute_name) >>
879 =head2 Required methods
883 =item B<< $metarole->get_required_method_list >>
885 Returns the list of methods required by the role.
887 =item B<< $metarole->requires_method($name) >>
889 Returns true if the role requires the named method.
891 =item B<< $metarole->add_required_methods(@names >>
893 Adds the named methods to the roles list of required methods.
895 =item B<< $metarole->remove_required_methods(@names) >>
897 Removes the named methods to the roles list of required methods.
901 =head2 Method modifiers
903 These methods act like their counterparts in L<Class::Mop::Class> and
904 L<Moose::Meta::Class>.
906 However, method modifiers are simply stored internally, and are not
907 applied until the role itself is applied to a class.
911 =item B<< $metarole->add_after_method_modifier($method_name, $method) >>
913 =item B<< $metarole->add_around_method_modifier($method_name, $method) >>
915 =item B<< $metarole->add_before_method_modifier($method_name, $method) >>
917 =item B<< $metarole->add_override_method_modifier($method_name, $method) >>
919 These methods all add an appropriate modifier to the internal list of
922 =item B<< $metarole->has_after_method_modifiers >>
924 =item B<< $metarole->has_around_method_modifiers >>
926 =item B<< $metarole->has_before_method_modifiers >>
928 =item B<< $metarole->has_override_method_modifier >>
930 Return true if the role has any modifiers of the given type.
932 =item B<< $metarole->get_after_method_modifiers($method_name) >>
934 =item B<< $metarole->get_around_method_modifiers($method_name) >>
936 =item B<< $metarole->get_before_method_modifiers($method_name) >>
938 Given a method name, returns a list of the appropriate modifiers for
941 =item B<< $metarole->get_override_method_modifier($method_name) >>
943 Given a method name, returns the override method modifier for that
944 method, if it has one.
952 =item B<< Moose::Meta::Role->meta >>
954 This will return a L<Class::MOP::Class> instance for this class.
960 All complex software has bugs lurking in it, and this module is no
961 exception. If you find a bug please either email me, or add the bug
966 Stevan Little E<lt>stevan@iinteractive.comE<gt>
968 =head1 COPYRIGHT AND LICENSE
970 Copyright 2006-2009 by Infinity Interactive, Inc.
972 L<http://www.iinteractive.com>
974 This library is free software; you can redistribute it and/or modify
975 it under the same terms as Perl itself.