moooooose
[gitmo/Moose.git] / lib / Moose.pm
1
2 package Moose;
3
4 use strict;
5 use warnings;
6
7 our $VERSION = '0.01';
8
9 use Scalar::Util 'blessed';
10 use Carp         'confess';
11
12 use Class::MOP;
13 use Moose::Object;
14
15 sub import {
16         shift;
17         my $pkg = caller();
18         
19         my $meta;
20         if ($pkg->can('meta')) {
21                 $meta = $pkg->meta();
22                 (blessed($meta) && $meta->isa('Class::MOP::Class'))
23                         || confess "Whoops, not møøsey enough";
24         }
25         else {
26                 $meta = Class::MOP::Class->initialize($pkg);
27         }
28
29         $meta->alias_method('has' => sub {
30                 my ($name, %options) = @_;
31                 my ($init_arg) = ($name =~ /^[\$\@\%][\.\:](.*)$/);
32                 $meta->add_attribute($name => (
33                         init_arg => $init_arg,
34                         %options,
35                 ));
36         });
37         
38         $meta->superclasses('Moose::Object') 
39                 unless $meta->superclasses();
40 }
41
42 1;
43
44 __END__
45
46 =pod
47
48 =head1 NAME
49
50 Moose - 
51
52 =head1 SYNOPSIS
53
54   package Point;
55   use Moose;
56   
57   has '$.x';
58   has '$.y' => (is => 'rw');
59   
60   sub clear {
61       my $self = shift;
62       $self->x(0);
63       $self->y(0);    
64   }
65   
66   package Point::3D;
67   use Moose;
68   
69   use base 'Point';
70   
71   has '$:z';
72   
73   sub clear : After {
74       my $self = shift;
75       $self->{'$:z'} = 0;
76   }
77
78 =head1 DESCRIPTION
79
80 =head1 OTHER NAMES
81
82 =head1 BUGS
83
84 All complex software has bugs lurking in it, and this module is no 
85 exception. If you find a bug please either email me, or add the bug
86 to cpan-RT.
87
88 =head1 CODE COVERAGE
89
90 I use L<Devel::Cover> to test the code coverage of my tests, below is the 
91 L<Devel::Cover> report on this module's test suite.
92
93 =head1 ACKNOWLEDGEMENTS
94
95 =head1 AUTHOR
96
97 Stevan Little E<lt>stevan@iinteractive.comE<gt>
98
99 =head1 COPYRIGHT AND LICENSE
100
101 Copyright 2006 by Infinity Interactive, Inc.
102
103 L<http://www.iinteractive.com>
104
105 This library is free software; you can redistribute it and/or modify
106 it under the same terms as Perl itself. 
107
108 =cut