X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FMethodAttributes.pm;h=8dfb0727c3078566786a7279ec34770920fd12a8;hb=28ef9468343a356954f0e4dc6bba1b834a8b3c3c;hp=0365dadda7f700d36d352655c9bbc4e624956427;hpb=12e7015aa9372aeaf1aaa7e125b8ac8da216deb5;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/MethodAttributes.pm b/lib/DBIx/Class/MethodAttributes.pm index 0365dad..8dfb072 100644 --- a/lib/DBIx/Class/MethodAttributes.pm +++ b/lib/DBIx/Class/MethodAttributes.pm @@ -158,6 +158,20 @@ sub VALID_DBIC_CODE_ATTRIBUTE { $_[1] =~ /^ DBIC_method_is_ (?: indirect_sugar + | + (?: bypassable | mandatory ) _resultsource_proxy + | + generated_from_resultsource_metadata + | + (?: inflated_ | filtered_ )? column_ (?: extra_)? accessor + | + single_relationship_accessor + | + (?: multi | filter ) _relationship_ (?: extra_ )? accessor + | + proxy_to_relationship + | + m2m_ (?: extra_)? sugar (?:_with_attrs)? ) $/x; } @@ -225,6 +239,155 @@ L and L. See also the check L. +=head3 DBIC_method_is_mandatory_resultsource_proxy + +=head3 DBIC_method_is_bypassable_resultsource_proxy + +The presence of one of these attributes on a L indicates +how DBIC will behave when someone calls e.g.: + + $some_result->result_source->add_columns(...) + +as opposed to the conventional + + SomeResultClass->add_columns(...) + +This distinction becomes important when someone declares a sub named after +one of the (currently 22) methods proxied from a +L to +L. While there are obviously no +problems when these methods are called at compile time, there is a lot of +ambiguity whether an override of something like +L will be respected by +DBIC and various plugins during runtime operations. + +It must be noted that there is a reason for this weird situation: during the +original design of DBIC the "ResultSourceProxy" system was established in +order to allow easy transition from Class::DBI. Unfortunately it was not +well abstracted away: it is rather difficult to use a custom ResultSource +subclass. The expansion of the DBIC project never addressed this properly +in the years since. As a result when one wishes to override a part of the +ResultSource functionality, the overwhelming practice is to hook a method +in a Result class and "hope for the best". + +The subtle changes of various internal call-chains in C make +this silent uncertainty untenable. As a solution any such override will now +issue a descriptive warning that it has been bypassed during a +C<< $rsrc->overriden_function >> invocation. A user B determine how +each individual override must behave in this situation, and tag it with one +of the above two attributes. + +Naturally any override marked with C<..._bypassable_resultsource_proxy> will +behave like it did before: it will be silently ignored. This is the attribute +you want to set if your code appears to work fine, and you do not wish to +receive the warning anymore (though you are strongly encouraged to understand +the other option). + +However overrides marked with C<..._mandatory_resultsource_proxy> will always +be reinvoked by DBIC itself, so that any call of the form: + + $some_result->result_source->columns_info(...) + +will be transformed into: + + $some_result->result_source->result_class->columns_info(...) + +with the rest of the callchain flowing out of that (provided the override did +invoke L where appropriate) + +=head3 DBIC_method_is_generated_from_resultsource_metadata + +This attribute is applied to all methods dynamically installed after various +invocations of L. Notably +this includes L, +L, +L +and the various L, +B the L (given its +effects are never reflected as C). + +=head3 DBIC_method_is_column_accessor + +This attribute is applied to all methods dynamically installed as a result of +invoking L. + +=head3 DBIC_method_is_inflated_column_accessor + +This attribute is applied to all methods dynamically installed as a result of +invoking L. + +=head3 DBIC_method_is_filtered_column_accessor + +This attribute is applied to all methods dynamically installed as a result of +invoking L. + +=head3 DBIC_method_is_*column_extra_accessor + +For historical reasons any L accessor is generated +twice as C<{name}> and C<_{name}_accessor>. The second method is marked with +C correspondingly. + +=head3 DBIC_method_is_single_relationship_accessor + +This attribute is applied to all methods dynamically installed as a result of +invoking L, +L or +L (though for C +see L<...filter_rel...|/DBIC_method_is_filter_relationship_accessor> below. + +=head3 DBIC_method_is_multi_relationship_accessor + +This attribute is applied to the main method dynamically installed as a result +of invoking L. + +=head3 DBIC_method_is_multi_relationship_extra_accessor + +This attribute is applied to the two extra methods dynamically installed as a +result of invoking L: +C<$relname_rs> and C. + +=head3 DBIC_method_is_filter_relationship_accessor + +This attribute is applied to (legacy) methods dynamically installed as a +result of invoking L with an +already-existing identically named column. The method is internally +implemented as an L +and is labeled with both atributes at the same time. + +=head3 DBIC_method_is_filter_relationship_extra_accessor + +Same as L. + +=head3 DBIC_method_is_proxy_to_relationship + +This attribute is applied to methods dynamically installed as a result of +providing L. + +=head3 DBIC_method_is_m2m_sugar + +=head3 DBIC_method_is_m2m_sugar_with_attrs + +One of the above attributes is applied to the main method dynamically +installed as a result of invoking +L. The C<_with_atrs> suffix +serves to indicate whether the user supplied any C<\%attrs> to the +C call. There is deliberately no mechanism to retrieve the actual +supplied values: if you really need this functionality you would need to rely on +L. + +=head3 DBIC_method_is_extra_m2m_sugar + +=head3 DBIC_method_is_extra_m2m_sugar_with_attrs + +One of the above attributes is applied to the extra B methods dynamically +installed as a result of invoking +L: C<$m2m_rs>, C, +C and C. + =head1 METHODS =head2 MODIFY_CODE_ATTRIBUTES