Skip to content

Commit

Permalink
Merge f5eeaf8 into 1ed1063
Browse files Browse the repository at this point in the history
  • Loading branch information
ufobat committed Aug 2, 2016
2 parents 1ed1063 + f5eeaf8 commit aea155c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/Rethinkdb.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ has 'term' => sub { Rethinkdb::Protocol->new->term; };

sub import {
my $class = shift;
my $package = caller;
my $package = caller || 'main';

no strict;
*{"$package\::r"} = \&r;
Expand All @@ -28,11 +28,13 @@ sub import {
}

sub r {
my $package = caller;
my $package = caller || 'main';
my $self;

if ($package::_rdb_io) {
$self = __PACKAGE__->new( io => $package::_rdb_io );
no strict "refs";
my $_rdb_io = ${$package . "::_rdb_io"};
if ($_rdb_io) {
$self = __PACKAGE__->new( io => $_rdb_io );
$self->io->_rdb($self);
}
else {
Expand Down
5 changes: 3 additions & 2 deletions lib/Rethinkdb/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ sub reconnect {
# put the handle into main package
sub repl {
my $self = shift;
my $package = caller;
my $package = caller || 'main';

$package::_rdb_io = $self;
no strict "refs";
${$package . "::_rdb_io"} = $self;
return $self;
}

Expand Down

0 comments on commit aea155c

Please sign in to comment.