1Class::C3::ComponentiseUds(e3r)Contributed Perl DocumentCaltaisosn::C3::Componentised(3)
2
3
4

NAME

6       Class::C3::Componentised
7

DESCRIPTION

9       Load mix-ins or components to your C3-based class.
10

SYNOPSIS

12         package MyModule;
13
14         use strict;
15         use warnings;
16
17         use base 'Class::C3::Componentised';
18
19         sub component_base_class { "MyModule::Component" }
20
21         package main;
22
23         MyModule->load_components( qw/Foo Bar/ );
24         # Will load MyModule::Component::Foo an MyModule::Component::Bar
25

DESCRIPTION

27       This will inject base classes to your module using the Class::C3 method
28       resolution order.
29
30       Please note: these are not plugins that can take precedence over meth‐
31       ods declared in MyModule. If you want something like that, consider
32       MooseX::Object::Pluggable.
33

METHODS

35       load_components( @comps )
36
37       Loads the given components into the current module. If a module begins
38       with a "+" character, it is taken to be a fully qualified class name,
39       otherwise "$class->component_base_class" is prepended to it.
40
41       Calling this will call "Class::C3::reinitialize".
42
43       load_own_components( @comps )
44
45       Simialr to load_components, but assumes every class is "$class::$comp".
46
47       load_optional_components
48
49       As load_components, but will silently ignore any components that cannot
50       be found.
51
52       ensure_class_loaded
53
54       Given a class name, tests to see if it is already loaded or otherwise
55       defined. If it is not yet loaded, the package is require'd, and an
56       exception is thrown if the class is still not loaded.
57
58        BUG: For some reason, packages with syntax errors are added to %INC on
59             require
60       =cut
61
62       # # TODO: handle ->has_many('rel', 'Class'...) instead of #
63       ->has_many('rel', 'Some::Schema::Class'...)  # sub ensure_class_loaded
64       {
65         my ($class, $f_class) = @_;
66
67         croak "Invalid class name $f_class"
68             if ($f_class=~m/(?:\b:\b⎪\:{3,})/);
69         return if Class::Inspector->loaded($f_class);
70         eval "require $f_class"; # require needs a bareword or filename
71         if ($@) {
72           if ($class->can('throw_exception')) {
73             $class->throw_exception($@);
74           } else {
75             croak $@;
76           }
77         }
78       }
79
80       ensure_class_found
81
82       Returns true if the specified class is installed or already loaded,
83       false otherwise
84
85       inject_base
86
87       Does the actual magic of adjusting @ISA on the target module.
88

AUTHOR

90       Matt S. Trout and the DBIx::Class team
91
92       Pulled out into seperate module by Ash Berlin "<ash@cpan.org>"
93

LICENSE

95       You may distribute this code under the same terms as Perl itself.
96
97
98
99perl v5.8.8                       2007-08-11       Class::C3::Componentised(3)
Impressum