1 package DBIx::Class::ResultSet::ParameterizedJoinHack;
5 use DBIx::Class::ParameterizedJoinHack;
6 use base qw(DBIx::Class::ResultSet);
8 sub _parameterized_join_store {
9 $_[0]->result_source->result_class
10 ->$DBIx::Class::ParameterizedJoinHack::STORE
13 sub with_parameterized_join {
14 my ($self, $rel, $params) = @_;
19 %{$self->{attrs}{join_parameters}||{}},
26 sub _localize_parameters {
27 my ($self, $final, $params, $store, $first, @rest) = @_;
28 return $final->() unless $first;
29 local $store->{$first}{params} = $params->{$first};
30 $self->_localize_parameters($final, $params, $store, @rest);
33 sub call_with_parameters {
34 my ($self, $method, @args) = @_;
35 my %params = %{$self->{attrs}{join_parameters}||{}};
36 my $store = $self->_parameterized_join_store;
37 return $self->_localize_parameters(
38 sub { $self->$method(@args) },
44 sub _resolved_attrs { my $self = shift; $self->call_with_parameters($self->next::can, @_) }
45 sub related_resultset { my $self = shift; $self->call_with_parameters($self->next::can, @_) }
51 DBIx::Class::ResultSet::ParameterizedJoinHack
55 package MySchema::ResultSet::Person;
56 use base qw(DBIx::Class::ResultSet);
58 __PACKAGE__->load_components(qw(ResultSet::ParameterizedJoinHack));
64 This is a ResultSet component allowing you to access the dynamically
65 parameterized relations declared with
66 L<DBIx::Class::ParameterizedJoinHack>.
68 Enable the component as usual with:
70 __PACKAGE__->load_components(qw( ResultSet::ParameterizedJoinHack ));
72 in your ResultSet class.
74 See L<DBIx::Class::ParameterizedJoinHack> for declaration documentation,
75 a general overview, and examples.
79 =head2 with_parameterized_join
81 my $joined_rs = $resultset->with_parameterized_join(
86 This method constructs a ResultSet joined with the given C<$relation_name>
87 by the passed C<$parameters>. The C<$relation_name> is the name as
88 declared on the Result, C<$parameters> is a hash reference with the keys
89 being the parameter names, and the values being the arguments to the join
94 Development of this module was sponsored by
98 =item * Ctrl O L<http://ctrlo.com>
104 Matt S. Trout <mst@shadowcat.co.uk>
112 Copyright (c) 2015 the DBIx::Class::ParameterizedJoinHack L</AUTHOR> and L</CONTRIBUTORS>
117 This library is free software and may be distributed under the same terms