Permalink
Browse files

Wtf?

  • Loading branch information...
2 parents 949824d + a6ff235 commit 8451a9f2a37838ea817686f9f0ea38e3677a8920 @gphat committed Jul 17, 2010
Showing with 45 additions and 3 deletions.
  1. +8 −2 Changes
  2. +24 −1 lib/Data/Manager.pm
  3. +13 −0 t/simple.t
View
10 Changes
@@ -1,7 +1,13 @@
Revision history for Data-Manager
-0.05 Jul 14, 2010
- - Use Message::Stack::Parser::DataVerifier for parsing Data::Verifier results
+0.06 Jul 16, 2010
+ - Use Message::Stack::Parser::DataVerifier for parsing Data::Verifier
+
+0.06 December 7th, 2009
+ - POD updates
+
+0.05 December 7th, 2009
+ - Fix busted release from poor merging.
0.04 December 2nd, 2009
- Don't process results with Message::Stack until lazy init time, allowing
View
@@ -7,7 +7,7 @@ with 'MooseX::Storage::Deferred';
use Message::Stack;
use Message::Stack::Parser::DataVerifier;
-our $VERSION = '0.05';
+our $VERSION = '0.07';
has 'messages' => (
is => 'ro',
@@ -61,6 +61,16 @@ sub _build_messages {
return $stack;
}
+sub success {
+ my ($self) = @_;
+
+ foreach my $res (keys %{ $self->results }) {
+ return 0 unless $self->get_results($res)->success;
+ }
+
+ return 1;
+}
+
sub verify {
my ($self, $scope, $data) = @_;
@@ -169,11 +179,24 @@ HashRef of L<Data::Verifier> objects, keyed by scope.
=head1 METHODS
+=head2 get_results ($scope)
+
+Gets the L<Data::Verifier::Results> object for the specified scope.
+
=head2 messages_for_scope ($scope)
Returns a L<Message::Stack> object containing messages for the specified
scope.
+=head2 set_results ($scope, $results)
+
+Sets the L<Data::Verifier::Results> object for the specified scope.
+
+=head2 success
+
+Convenience method that checks C<success> on each of the results in this
+manager. Returns false if any are false.
+
=head2 verify ($scope, $data);
Verify the data against the specified scope. After verification the results
View
@@ -33,4 +33,17 @@ my $stack = $dm->messages_for_scope('name1');
isa_ok($stack, 'Message::Stack');
cmp_ok($stack->count, '==', 1, '1 message');
+ok(!$dm->success, 'verification did not succeed');
+
+{
+ my $dm2 = Data::Manager->new;
+ $dm2->set_verifier('name1', $verifier);
+ $dm2->verify('name1', { name_first => 'Cory', name_last => 'Watson' });
+ ok($dm2->success, 'successful');
+
+ $dm2->set_verifier('name2', $verifier);
+ $dm2->verify('name2', { name_first => 'Cory' });
+ ok(!$dm2->success, 'not successful');
+}
+
done_testing;

0 comments on commit 8451a9f

Please sign in to comment.