Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use MooseX::Params::Validate

Now the parameters are type checked.
  • Loading branch information...
commit dc3be8408a018e73f149c96fc86085a5dbcb2ef8 1 parent 85f84b5
@masak authored
Showing with 16 additions and 15 deletions.
  1. +16 −15 perl5/lib/Data/Object.pm
View
31 perl5/lib/Data/Object.pm
@@ -1,5 +1,6 @@
package Data::Object;
use Moose::Role;
+use MooseX::Params::Validate;
has 'L' => (is => 'rw', isa => 'Data::Object', builder => '_point_to_self');
has 'R' => (is => 'rw', isa => 'Data::Object', builder => '_point_to_self');
@@ -13,11 +14,11 @@ sub _point_to_self {
}
sub attach_below {
- my ($self, $other) = @_;
-
- # XXX: Should do typechecking of $other here with
- # MooseX::Params::Validate, but am offline
- # and don't have the module.
+ my $self = shift;
+ my ($other) = pos_validated_list(
+ \@_,
+ { isa => 'Data::Object' },
+ );
$other->D->U($self);
$self->D($other->D);
@@ -27,11 +28,11 @@ sub attach_below {
}
sub attach_to_right_of {
- my ($self, $other) = @_;
-
- # XXX: Should do typechecking of $other here with
- # MooseX::Params::Validate, but am offline
- # and don't have the module.
+ my $self = shift;
+ my ($other) = pos_validated_list(
+ \@_,
+ { isa => 'Data::Object' },
+ );
$other->R->L($self);
$self->R($other->R);
@@ -41,11 +42,11 @@ sub attach_to_right_of {
}
sub attach_to_left_of {
- my ($self, $other) = @_;
-
- # XXX: Should do typechecking of $other here with
- # MooseX::Params::Validate, but am offline
- # and don't have the module.
+ my $self = shift;
+ my ($other) = pos_validated_list(
+ \@_,
+ { isa => 'Data::Object' },
+ );
$other->attach_to_right_of($self);
}
Please sign in to comment.
Something went wrong with that request. Please try again.