Created
August 17, 2012 12:17
-
-
Save motemen/3378389 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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