-
-
Save dhoss/1223383 to your computer and use it in GitHub Desktop.
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 MyApp::Web::Model::DataManager; | |
use Moose; | |
use Email::Valid; | |
extends 'Catalyst::Model'; | |
with 'Catalyst::Component::InstancePerContext'; | |
my $email_filter = sub { | |
my @ret = Email::Valid->address( shift ); | |
return $ret[0]; | |
}; | |
my $bool_filter = sub { $_[0] ? 1 : 0; }; | |
has 'profiles' => ( | |
is => 'ro', | |
isa => 'HashRef', | |
traits => [ 'Hash' ], | |
handles => { | |
'get_profile' => 'get', | |
'scopes' => 'keys', | |
}, | |
default => sub { { | |
# Personal/Account Information | |
'login' => { | |
# ... | |
} | |
} }, | |
); | |
sub build_per_context_instance { | |
my ( $self, $c ) = @_; | |
my %dm_args = (); | |
if ( $c->stash->{messages} ) { | |
$dm_args{messages} = $c->stash->{messages}; | |
} | |
my $dm = Data::Manager->new( %dm_args ); | |
foreach my $scope ( $self->scopes ) { | |
$dm->set_verifier( | |
$scope => Data::Verifier->new( $self->get_profile($scope) ) | |
); | |
} | |
return $dm; | |
} | |
no Moose; | |
__PACKAGE__->meta->make_immutable; 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment