package IdPAccountManager::ServiceProvider; use strict; use warnings; use base 'IdPAccountManager::DB::Object'; use List::MoreUtils qw(any); __PACKAGE__->meta->setup( table => 'serviceproviders', columns => [ id => { type => 'bigserial', not_null => 1 }, entityid => { type => 'varchar', length => 200, not_null => 1 }, displayname => { type => 'varchar', length => 500 }, contacts => { type => 'array' }, ], primary_key_columns => [ 'id' ], unique_key => [ 'entityid' ], ); ## Print the content of a test account sub print { my ($self, $fd) = @_; $fd = \*STDOUT unless $fd; printf $fd "ServiceProvider ID=%s; entityid=%s; displayname=%s; contacts=%s\n", $self->id(), $self->entityid(), $self->displayname(), join(',', $self->contacts()); } ## Check if email address is a known contact sub is_contact { my ($self, $email) = @_; $email = lc($email); return any { $email eq lc($_) } $self->contacts(); } 1;