Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package DBIx::Lite::ResultSet::Role::Slave;
use strict;
use warnings;
use Role::Tiny;
around $_ => sub {
my ($ORIG, $self, @args) = @_;
local $self->{dbix_lite} = $self->{dbix_lite}->master;
return $self->$ORIG(@args);
} for qw(
insert
delete
update
);
1;
package DBIx::Lite::Role::Slave;
use strict;
use warnings;
use Role::Tiny;
requires 'master';
around table => sub {
my ($ORIG, $self, @args) = @_;
my $table = $self->$ORIG(@args);
return Role::Tiny->apply_roles_to_object(
$table, 'DBIx::Lite::ResultSet::Role::Slave',
);
};
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.