1DBIx::Class::IntrospectUasbelreMC2oMn(t3r)ibuted Perl DoDcBuImxe:n:tCaltaisosn::IntrospectableM2M(3)
2
3
4
6 DBIx::Class::IntrospectableM2M - Introspect many-to-many shortcuts
7
9 In your DBIx::Class Result class (sometimes erroneously referred to as
10 the 'table' class):
11
12 __PACKAGE__->load_components(qw/IntrospectableM2M ... Core/);
13
14 #Digest encoder with hex format and SHA-1 algorithm
15 __PACKAGE__->many_to_many(roles => user_roles => 'role);
16
17 When you want to introspect this data
18
19 my $metadata = $result_class->_m2m_metadata->{roles};
20 # $metadata->{accessor} method name e.g. 'roles'
21 # $metadata->{relation} maping relation e.g. 'user_roles'
22 # $metadata->{foreign_relation} far-side relation e.g. 'role
23 # $metadata->{attrs} relationship attributes, if any
24 # Convenience methods created by DBIx::Class
25 # $metadata->{rs_method} 'roles_rs'
26 # $metadata->{add_method} 'add_to_roles',
27 # $metadata->{set_method} 'set_roles',
28 # $metadata->{remove_method} 'remove_from_roles'
29
30 Note: The component needs to be loaded before Core.
31
33 This module is fairly esoteric and, unless you are dynamically creating
34 something out of a DBIC Schema, is probably the wrong solution for
35 whatever it is you are trying to do. Please be advised that
36 compatibility is not guaranteed for DBIx::Class 0.09000+. We will try
37 to manitain all compatibility, but internal changes might make it
38 impossible.
39
41 Because the many-to-many relationships are not real relationships, they
42 can not be introspected with DBIx::Class. Many-to-many relationships
43 are actually just a collection of convenience methods installed to
44 bridge two relationships. This DBIx::Class component can be used to
45 store all relevant information about these non-relationships so they
46 can later be introspected and examined.
47
49 many_to_many
50 Extended to store all relevant information in the "_m2m_metadata" HASH
51 ref.
52
53 _m2m_metadata
54 Accessor to a HASH ref where the keys are the names of m2m
55 relationships and the value is a HASH ref as described in the SYNOPSIS.
56
58 Guillermo Roditi (groditi) <groditi@cpan.org>
59
61 Copyright (C) 2008 by Guillermo Roditi
62
63 This library is free software; you can redistribute it and/or modify it
64 under the same terms as Perl itself.
65
66
67
68perl v5.34.0 2021-07-22 DBIx::Class::IntrospectableM2M(3)