Merge 'bulk_create' into 'DBIx-Class-current'
[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
38Closer to being aboe to do a Serialize::Storable that doesn't require class-based connections
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
64sub STORABLE_freeze {
65 my ($self, $cloning) = @_;
66 my $to_serialize = { %$self };
67 delete $to_serialize->{schema};
68 return (Storable::freeze($to_serialize));
69}
70
71sub STORABLE_thaw {
72 my ($self, $cloning,$ice) = @_;
73 %$self = %{ Storable::thaw($ice) };
74}
75
761;