Commit | Line | Data |
64468268 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | package MooseX::InsideOut; |
fff3c901 |
5 | # ABSTRACT: inside-out objects with Moose |
64468268 |
6 | |
fda3c8a5 |
7 | use MooseX::InsideOut::Meta::Class; |
8 | BEGIN { require Moose } |
9 | use Carp; |
64468268 |
10 | |
fda3c8a5 |
11 | sub import { |
12 | my $class = shift; |
13 | |
14 | if (@_) { Carp::confess "$class has no exports" } |
15 | |
16 | my $into = caller; |
17 | |
18 | return if $into eq 'main'; |
19 | |
20 | Moose::init_meta( |
21 | $into, |
22 | 'Moose::Object', |
23 | 'MooseX::InsideOut::Meta::Class', |
24 | ); |
25 | |
26 | Moose->import({ into => $into }); |
27 | |
28 | return; |
29 | } |
0a374e17 |
30 | |
64468268 |
31 | 1; |
32 | __END__ |
33 | |
64468268 |
34 | =head1 SYNOPSIS |
35 | |
36 | package My::Object; |
37 | |
fda3c8a5 |
38 | use MooseX::InsideOut; |
64468268 |
39 | |
40 | # ... normal Moose functionality |
41 | # or ... |
42 | |
43 | package My::Subclass; |
44 | |
45 | use metaclass 'MooseX::InsideOut::Meta::Class'; |
46 | use Moose; |
fda3c8a5 |
47 | extends 'Some::Other::Class'; |
64468268 |
48 | |
49 | =head1 DESCRIPTION |
50 | |
51 | MooseX::InsideOut provides a metaclass and an instance metaclass for inside-out |
52 | objects. |
53 | |
fda3c8a5 |
54 | You can use MooseX::InsideOut, as in the first example in the L</SYNOPSIS>. |
55 | This sets up the metaclass and instance metaclass for you, as well as importing |
56 | all of the normal Moose goodies. |
64468268 |
57 | |
58 | You can also use the metaclass C<MooseX::InsideOut::Meta::Class> directly, as |
59 | in the second example. This is most useful when extending a non-Moose class, |
60 | whose internals you either don't want to care about or aren't hash-based. |
61 | |
62 | =head1 TODO |
63 | |
64 | =over |
65 | |
66 | =item * dumping (for debugging purposes) |
67 | |
68 | =item * serialization (for e.g. storable) |
69 | |
70 | =item * (your suggestions here) |
71 | |
72 | =back |
73 | |
64468268 |
74 | =cut |