ResultSetColumn::func() now returns all results if called in list context
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSourceHandle.pm
CommitLineData
aec3eff1 1package DBIx::Class::ResultSourceHandle;
2
3use strict;
4use warnings;
5use Storable;
6
7use base qw/DBIx::Class/;
8
9use overload
3441fd57 10 q/""/ => sub { __PACKAGE__ . ":" . shift->source_moniker; },
aec3eff1 11 fallback => 1;
12
3441fd57 13__PACKAGE__->mk_group_accessors('simple' => qw/schema source_moniker/);
aec3eff1 14
15=head1 NAME
16
17DBIx::Class::ResultSourceHandle
18
19=head1 DESCRIPTION
20
21This module removes fixed link between Rows/ResultSets and the actual source
22objects, which gets round the following problems
23
24=over 4
25
26=item *
27
28Needing to keep C<$schema> in scope, since any objects/result_sets
29will have a C<$schema> object through their source handle
30
31=item *
32
33Large output when using Data::Dump(er) since this class can be set to
34stringify to almost nothing
35
36=item *
37
7137528d 38Closer to being able to do a Serialize::Storable that doesn't require class-based connections
aec3eff1 39
40=back
41
42=head1 METHODS
43
44=head2 new
45
46=cut
47
48sub new {
49 my ($class, $data) = @_;
50
51 $class = ref $class if ref $class;
52
53 bless $data, $class;
54}
55
56=head2 resolve
57
3441fd57 58Resolve the moniker into the actual ResultSource object
aec3eff1 59
60=cut
61
3441fd57 62sub resolve { return $_[0]->schema->source($_[0]->source_moniker) }
aec3eff1 63
7137528d 64=head2 STORABLE_freeze
65
66Freezes a handle.
67
68=cut
69
aec3eff1 70sub STORABLE_freeze {
71 my ($self, $cloning) = @_;
72 my $to_serialize = { %$self };
73 delete $to_serialize->{schema};
74 return (Storable::freeze($to_serialize));
75}
76
7137528d 77=head2 STORABLE_thaw
78
79Thaws frozen handle.
80
81=cut
82
aec3eff1 83sub STORABLE_thaw {
84 my ($self, $cloning,$ice) = @_;
85 %$self = %{ Storable::thaw($ice) };
86}
87
881;