license => 'perl',
requires => {
'Scalar::Util' => '1.18',
- 'Carp' => '0.01',
- 'Class::MOP' => '0.20',
+ 'Carp' => '0',
+ 'Class::MOP' => '0.21',
'Sub::Name' => '0.02',
},
optional => {
--- /dev/null
+Revision history for Perl extension Moose
+
+0.01 Wed. March 15, 2006
+ - Moooooooooooooooooose!!!
\ No newline at end of file
+Build.PL
+Changes
+Makefile.PL
+META.yml
+MANIFEST
+MANIFEST.SKIP
+README
+lib/Moose.pm
+lib/Moose/Object.pm
+lib/Moose/Meta/Attribute.pm
+lib/Moose/Meta/Class.pm
+lib/Moose/Util/TypeConstraints.pm
+t/000_load.t
+t/001_basic.t
+t/002_basic.t
+t/003_basic.t
+t/010_basic_class_setup.t
+t/020_foreign_inheritence.t
+t/050_util_type_constraints.t
+t/051_util_type_constraints_export.t
+t/052_util_std_type_constraints.t
+t/pod.t
+t/pod_coverage.t
-use lib '/Users/stevan/CPAN/Class-MOP/Class-MOP/lib';
-
package Moose;
use strict;
else {
$meta = Moose::Meta::Class->initialize($pkg => (
':attribute_metaclass' => 'Moose::Meta::Attribute'
- ));
+ ));
+ $meta->add_method('meta' => sub {
+ # re-initialize so it inherits properly
+ Moose::Meta::Class->initialize($pkg => (
+ ':attribute_metaclass' => 'Moose::Meta::Attribute'
+ ));
+ })
}
# NOTE:
=head1 NAME
-Moose -
+Moose - Moose, it's the new Camel
=head1 SYNOPSIS
+
+ package Point;
+ use Moose;
+
+ has 'x' => (isa => Int(), is => 'rw');
+ has 'y' => (isa => Int(), is => 'rw');
+
+ sub clear {
+ my $self = shift;
+ $self->x(0);
+ $self->y(0);
+ }
+
+ package Point3D;
+ use Moose;
+
+ extends 'Point';
+ has 'z' => (isa => Int());
+
+ after 'clear' => sub {
+ my $self = shift;
+ $self->{z} = 0;
+ };
+
+=head1 CAVEAT
+
+This is a B<very> early release of this module, it still needs
+some fine tuning and B<lots> more documentation. I am adopting
+the I<release early and release often> approach with this module,
+so keep an eye on your favorite CPAN mirror!
+
=head1 DESCRIPTION
-=head1 OTHER NAMES
+Moose is an extension of the Perl 5 object system.
+
+=head2 Another object system!?!?
-Makes Other Object Systems Envious
+Yes, I know there has been an explosion recently of new ways to
+build object's in Perl 5, most of them based on inside-out objects,
+and other such things. Moose is different because it is not a new
+object system for Perl 5, but instead an extension of the existing
+object system.
-Makes Object Orientation So Easy
+Moose is built on top of L<Class::MOP>, which is a metaclass system
+for Perl 5. This means that Moose not only makes building normal
+Perl 5 objects better, but is also provides brings with it the power
+of metaclass programming.
+
+=head2 What does Moose stand for??
+
+Moose doesn't stand for one thing in particular, however, if you
+want, here are a few of my favorites, feel free to contribute
+more :)
+
+=over 4
+
+=item Makes Other Object Systems Envious
+
+=item Makes Object Orientation So Easy
+
+=back
=head1 BUGS
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
=head1 NAME
-Moose::Meta::Attribute -
+Moose::Meta::Attribute - The Moose attribute metaobject
=head1 SYNOPSIS
=head1 DESCRIPTION
+This is a subclass of L<Class::MOP::Attribute> with Moose specific
+extensions.
+
=head1 METHODS
=over 4
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
sub construct_instance {
my ($class, %params) = @_;
- my $instance = {};
+ my $instance = $params{'__INSTANCE__'} || {};
foreach my $attr ($class->compute_all_applicable_attributes()) {
my $init_arg = $attr->init_arg();
# try to fetch the init arg from the %params ...
=head1 NAME
-Moose::Meta::Class -
+Moose::Meta::Class - The Moose metaclass
=head1 SYNOPSIS
=head1 DESCRIPTION
+This is a subclass of L<Class::MOP::Class> with Moose specific
+extensions.
+
=head1 METHODS
=over 4
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
=head1 NAME
-Moose::Object -
+Moose::Object - The base object for Moose
-=head1 SYNOPSIS
+=head1 SYNOPSIS
=head1 DESCRIPTION
=item B<new>
+This will create a new instance and call C<BUILDALL>.
+
=item B<BUILDALL>
+This will call every C<BUILD> method in the inheritance hierarchy.
+
=item B<DEMOLISHALL>
+This will call every C<DEMOLISH> method in the inheritance hierarchy.
+
=back
=head1 BUGS
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
=head1 NAME
-Moose::Util::TypeConstraints -
+Moose::Util::TypeConstraints - Type constraint system for Moose
=head1 SYNOPSIS
=head1 DESCRIPTION
+This module provides Moose with the ability to create type contraints
+to be are used in both attribute definitions and for method argument
+validation.
+
+This is B<NOT> a type system for Perl 5.
+
+The type and subtype constraints are basically functions which will
+validate their first argument. If called with no arguments, they will
+return themselves (this is syntactic sugar for Moose attributes).
+
+This module also provides a simple hierarchy for Perl 5 types, this
+could probably use some work, but it works for me at the moment.
+
+ Any
+ Value
+ Int
+ Str
+ Ref
+ ScalarRef
+ ArrayRef
+ HashRef
+ CodeRef
+ RegexpRef
+ Object
+
+Suggestions for improvement are welcome.
+
=head1 FUNCTIONS
=head2 Type Constraint Constructors
exception. If you find a bug please either email me, or add the bug
to cpan-RT.
-=head1 CODE COVERAGE
-
-I use L<Devel::Cover> to test the code coverage of my tests, below is the
-L<Devel::Cover> report on this module's test suite.
-
-=head1 ACKNOWLEDGEMENTS
-
=head1 AUTHOR
Stevan Little E<lt>stevan@iinteractive.comE<gt>
use strict;
use warnings;
-use Test::More tests => 41;
+use Test::More tests => 43;
use Test::Exception;
BEGIN {
[ 'Moose::Object' ],
'... Point got the automagic base class');
-my @Point_methods = qw(x y clear);
+my @Point_methods = qw(meta x y clear);
my @Point_attrs = ('x', 'y');
is_deeply(
[ 'Point' ],
'... Point3D gets the parent given to it');
-my @Point3D_methods = qw(clear);
+my @Point3D_methods = qw(meta clear);
my @Point3D_attrs = ('z');
is_deeply(
can_ok('Foo', 'meta');
isa_ok(Foo->meta, 'Moose::Meta::Class');
-ok(!Foo->meta->has_method('meta'), '... we get the &meta method from Moose::Object');
+ok(Foo->meta->has_method('meta'), '... we got the &meta method');
ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object');
foreach my $function (qw(
--- /dev/null
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use Test::Exception;
+
+BEGIN {
+ use_ok('Moose');
+}
+
+{
+ package Elk;
+ use strict;
+ use warnings;
+
+ sub new {
+ my $class = shift;
+ bless { no_moose => "Elk" } => $class;
+ }
+
+ sub no_moose { $_[0]->{no_moose} }
+
+ package Foo::Moose;
+ use strict;
+ use warnings;
+ use Moose;
+
+ extends 'Elk';
+
+ has 'moose' => (is => 'ro', default => 'Foo');
+
+ sub new {
+ my $class = shift;
+ my $super = $class->SUPER::new(@_);
+ return $class->meta->new_object('__INSTANCE__' => $super, @_);
+ }
+}
+
+my $foo_moose = Foo::Moose->new();
+isa_ok($foo_moose, 'Foo::Moose');
+isa_ok($foo_moose, 'Elk');
+
+is($foo_moose->no_moose, 'Elk', '... got the right value from the Elk method');
+is($foo_moose->moose, 'Foo', '... got the right value from the Foo::Moose method');
\ No newline at end of file