aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/Alert.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-05-26 17:17:24 +0100
committerStruan Donald <struan@exo.org.uk>2011-05-26 17:17:24 +0100
commit860f2965f9af0699a40e022ba7c7370a304a4313 (patch)
tree3cf65ef4fedf85a343d3d290288b73d26b4585fa /perllib/FixMyStreet/DB/Result/Alert.pm
parentf7a711c5b544d876928ba572f46912e09eff9b83 (diff)
use moose role for is_from_abuser method
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Alert.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/Alert.pm31
1 files changed, 6 insertions, 25 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Alert.pm b/perllib/FixMyStreet/DB/Result/Alert.pm
index d780e91fd..e0017b94d 100644
--- a/perllib/FixMyStreet/DB/Result/Alert.pm
+++ b/perllib/FixMyStreet/DB/Result/Alert.pm
@@ -57,32 +57,10 @@ __PACKAGE__->belongs_to(
# You can replace this text with custom code or comments, and it will be preserved on regeneration
-# FIXME: this is more or less duplicated from problem. need to stick somewhere common
+use Moose;
+use namespace::clean -except => [ 'meta' ];
-
-=head2 is_from_abuser
-
- $bool = $alert->is_from_abuser( );
-
-Returns true if the user's email or its domain is listed in the 'abuse' table.
-
-=cut
-
-sub is_from_abuser {
- my $self = shift;
-
- # get the domain
- my $email = $self->user->email;
- my ($domain) = $email =~ m{ @ (.*) \z }x;
-
- # search for an entry in the abuse table
- my $abuse_rs = $self->result_source->schema->resultset('Abuse');
-
- return
- $abuse_rs->find( { email => $email } )
- || $abuse_rs->find( { email => $domain } )
- || undef;
-}
+with 'FixMyStreet::Roles::Abuser';
=head2 confirm
@@ -103,4 +81,7 @@ sub confirm {
return 1;
}
+# need the inline_constuctor bit as we don't inherit from Moose
+__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
+
1;