fucking attributes dont work right ,... damn you perl,.. damn you
[gitmo/Moose.git] / lib / Moose.pm
CommitLineData
fcd84ca9 1
2package Moose;
3
4use strict;
5use warnings;
6
7our $VERSION = '0.01';
8
9use Scalar::Util 'blessed';
10use Carp 'confess';
11
12use Class::MOP;
13use Moose::Object;
14
15sub 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 });
3c7278fb 37
09fdc1dc 38 $meta->alias_method('before' => sub { $meta->add_before_method_modifier(@_) });
39 $meta->alias_method('after' => sub { $meta->add_after_method_modifier(@_) });
40 $meta->alias_method('around' => sub { $meta->add_around_method_modifier(@_) });
fcd84ca9 41
42 $meta->superclasses('Moose::Object')
43 unless $meta->superclasses();
44}
45
461;
47
48__END__
49
50=pod
51
52=head1 NAME
53
54Moose -
55
56=head1 SYNOPSIS
57
58 package Point;
59 use Moose;
60
09fdc1dc 61 has '$.x' => (reader => 'x');
62 has '$.y' => (accessor => 'y');
fcd84ca9 63
64 sub clear {
65 my $self = shift;
09fdc1dc 66 $self->{'$.x'} = 0;
fcd84ca9 67 $self->y(0);
68 }
69
09fdc1dc 70 package Point3D;
fcd84ca9 71 use Moose;
72
73 use base 'Point';
74
75 has '$:z';
76
09fdc1dc 77 after 'clear' => sub {
fcd84ca9 78 my $self = shift;
79 $self->{'$:z'} = 0;
09fdc1dc 80 };
81
fcd84ca9 82=head1 DESCRIPTION
83
84=head1 OTHER NAMES
85
3c7278fb 86Makes Other Object Systems Envious
87
88Most Other Objects Suck Eggs
89
90Makes Object Orientation So Easy
91
92Metacircular Object Oriented Systems Environment
93
fcd84ca9 94=head1 BUGS
95
96All complex software has bugs lurking in it, and this module is no
97exception. If you find a bug please either email me, or add the bug
98to cpan-RT.
99
100=head1 CODE COVERAGE
101
102I use L<Devel::Cover> to test the code coverage of my tests, below is the
103L<Devel::Cover> report on this module's test suite.
104
105=head1 ACKNOWLEDGEMENTS
106
107=head1 AUTHOR
108
109Stevan Little E<lt>stevan@iinteractive.comE<gt>
110
111=head1 COPYRIGHT AND LICENSE
112
113Copyright 2006 by Infinity Interactive, Inc.
114
115L<http://www.iinteractive.com>
116
117This library is free software; you can redistribute it and/or modify
118it under the same terms as Perl itself.
119
120=cut