Created
March 9, 2015 18:02
-
-
Save ichesnokov/e5fb7e70cb6d497ea5a0 to your computer and use it in GitHub Desktop.
overridden new()
This file contains 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 My::DB::ResultSet::Service; | |
use our::way; | |
use parent 'DBIx::Class::ResultSet'; | |
# Wrapper to exclude services with 'deleted' status from search | |
sub new { | |
my $class = shift; | |
my $self = $class->next::method(@_); | |
my $status_alias = $self->current_source_alias . '.status'; | |
# Fuck with resultset internals | |
$self->{attrs}->{where} = $self->_stack_cond( | |
$self->{attrs}->{where}, | |
{ $status_alias => { '!=' => 'deleted' } }, | |
); | |
$self->{cond} = $self->{attrs}->{where}; | |
return $self; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment