use Moose;
use Moose::Util::TypeConstraints;
-our $VERSION = '0.04';
+our $VERSION = '0.16';
+$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
extends 'Moose::Meta::Attribute';
default => sub {{}}
);
-
# these next two are the possible methods
# you can use in the 'provides' map.
# extend the parents stuff to make sure
# certain bits are now required ...
-has '+$!default' => (required => 1);
+has '+default' => (required => 1);
has '+type_constraint' => (required => 1);
## Methods called prior to instantiation
## methods called after instantiation
-# this confirms that provides has
+# this confirms that provides (and curries) has
# all valid possibilities in it
sub check_provides_values {
my $self = shift;
(exists $method_constructors->{$key})
|| confess "$key is an unsupported method type";
}
+
+ foreach my $key (keys %{$self->curries}) {
+ (exists $method_constructors->{$key})
+ || confess "$key is an unsupported method type";
+ }
}
sub _curry {
my $code = shift;
my @args = @_;
- return sub { my $self = shift; $code->($self, @args, @_) };
+ return sub {
+ my $self = shift;
+ $code->($self, @args, @_)
+ };
}
sub _curry_sub {
my $body = shift;
my $code = shift;
- warn "installing sub!";
-
- return sub { my $self = shift; $code->($self, $body, @_) };
+ return sub {
+ my $self = shift;
+ $code->($self, $body, @_)
+ };
}
after 'install_accessors' => sub {
# before we install them, lets
# make sure they are valid
$attr->check_provides_values;
-# $attr->check_curries_values;
my $method_constructors = $attr->method_constructors;
after 'remove_accessors' => sub {
my $attr = shift;
my $class = $attr->associated_class;
+
+ # provides accessors
foreach my $key (keys %{$attr->provides}) {
my $method_name = $attr->provides->{$key};
my $method = $class->get_method($method_name);
if blessed($method) &&
$method->isa('MooseX::AttributeHelpers::Meta::Method::Provided');
}
+
+ # curries accessors
+ foreach my $key (keys %{$attr->curries}) {
+ my $method_name = $attr->curries->{$key};
+ my $method = $class->get_method($method_name);
+ $class->remove_method($method_name)
+ if blessed($method) &&
+ $method->isa('MooseX::AttributeHelpers::Meta::Method::Provided');
+ }
};
no Moose;
=item B<provides>
+=item B<curries>
+
=item B<method_provider>
=item B<method_constructors>
=over 4
-=item B<$!default>
+=item B<default>
-C<$!default> is now required.
+C<default> is now required.
=item B<type_constraint>