Skip to content

Instantly share code, notes, and snippets.

@ichesnokov
Created March 9, 2015 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichesnokov/e5fb7e70cb6d497ea5a0 to your computer and use it in GitHub Desktop.
Save ichesnokov/e5fb7e70cb6d497ea5a0 to your computer and use it in GitHub Desktop.
overridden new()
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