is => 'ro',
isa => 'Int',
default => sub { 0 },
- provides => {
- inc => 'inc_counter',
- dec => 'dec_counter',
- reset => 'reset_counter',
- set => 'set_counter'
+ handles => {
+ inc_counter => 'inc',
+ dec_counter => 'dec',
+ reset_counter => 'reset',
+ set_counter => 'set'
}
);
}
is($counter->type_constraint->name, 'Int', '... got the expected type constraint');
-is_deeply($counter->provides, {
- inc => 'inc_counter',
- dec => 'dec_counter',
- reset => 'reset_counter',
- set => 'set_counter'
-}, '... got the right provides methods');
+is_deeply($counter->handles, {
+ inc_counter => 'inc',
+ dec_counter => 'dec',
+ reset_counter => 'reset',
+ set_counter => 'set'
+}, '... got the right handles methods');
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [] },
- provides => {
- 'push' => 'add_options',
- 'pop' => 'remove_last_option',
- 'shift' => 'remove_first_option',
- 'unshift' => 'insert_options',
- 'get' => 'get_option_at',
- 'set' => 'set_option_at',
- 'count' => 'num_options',
- 'empty' => 'has_options',
- 'clear' => 'clear_options',
- 'splice' => 'splice_options',
- 'sort_in_place' => 'sort_options_in_place',
- 'accessor' => 'option_accessor',
- },
- curries => {
- 'push' => {
- add_options_with_speed => ['funrolls', 'funbuns']
- },
- 'unshift' => {
- prepend_prerequisites_along_with => ['first', 'second']
- },
- 'sort_in_place' => { descending_options => [ sub { $_[1] <=> $_[0] } ],
+ handles => {
+ 'add_options' => 'push',
+ 'remove_last_option' => 'pop',
+ 'remove_first_option' => 'shift',
+ 'insert_options' => 'unshift',
+ 'get_option_at' => 'get',
+ 'set_option_at' => 'set',
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'clear_options' => 'clear',
+ 'splice_options' => 'splice',
+ 'sort_options_in_place' => 'sort_in_place',
+ 'option_accessor' => 'accessor',
+ 'add_optons_with_speed' =>
+ [ 'push' => ['funrolls', 'funbuns'] ],
+ 'prepend_prerequisites_along_with' =>
+ [ 'unshift' => ['first', 'second'] ],
+ 'descending_options' =>
+ [ 'sort_in_place' => [ sub { $_[1] <=> $_[0] } ] ],
},
}
);
my $options = $stuff->meta->get_attribute('options');
isa_ok($options, 'Moose::AttributeHelpers::Collection::Array');
-is_deeply($options->provides, {
- 'push' => 'add_options',
- 'pop' => 'remove_last_option',
- 'shift' => 'remove_first_option',
- 'unshift' => 'insert_options',
- 'get' => 'get_option_at',
- 'set' => 'set_option_at',
- 'count' => 'num_options',
- 'empty' => 'has_options',
- 'clear' => 'clear_options',
- 'splice' => 'splice_options',
- 'sort_in_place' => 'sort_options_in_place',
- 'accessor' => 'option_accessor',
-}, '... got the right provides mapping');
+is_deeply($options->handles,
+ 'add_options' => 'push',
+ 'remove_last_option' => 'pop',
+ 'remove_first_option' => 'shift',
+ 'insert_options' => 'unshift',
+ 'get_option_at' => 'get',
+ 'set_option_at' => 'set',
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'clear_options' => 'clear',
+ 'splice_options' => 'splice',
+ 'sort_options_in_place' => 'sort_in_place',
+ 'option_accessor' => 'accessor',
+}, '... got the right handles mapping');
is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
is => 'ro',
isa => 'HashRef[Str]',
default => sub { {} },
- provides => {
- 'set' => 'set_option',
- 'get' => 'get_option',
- 'empty' => 'has_options',
- 'count' => 'num_options',
- 'clear' => 'clear_options',
- 'delete' => 'delete_option',
- 'exists' => 'has_option',
- 'defined' => 'is_defined',
- 'accessor' => 'option_accessor',
- 'kv' => 'key_value',
- 'elements' => 'options_elements',
+ handles => {
+ 'set_option' => 'set',
+ 'get_option' => 'get',
+ 'has_options' => 'empty',
+ 'num_options' => 'count',
+ 'clear_options' => 'clear',
+ 'delete_option' => 'delete',
+ 'has_option' => 'exists',
+ 'is_defined' => 'defined',
+ 'option_accessor' => 'accessor',
+ 'key_value' => 'kv',
+ 'options_elements' => 'elements',
+ 'quantity' => [ accessor => ['quantity'] ],
},
- curries => {
- 'accessor' => {
- quantity => ['quantity'],
- },
- }
);
}
my $options = $stuff->meta->get_attribute('options');
isa_ok($options, 'Moose::AttributeHelpers::Collection::Hash');
-is_deeply($options->provides, {
- 'set' => 'set_option',
- 'get' => 'get_option',
- 'empty' => 'has_options',
- 'count' => 'num_options',
- 'clear' => 'clear_options',
- 'delete' => 'delete_option',
- 'defined' => 'is_defined',
- 'exists' => 'has_option',
- 'accessor' => 'option_accessor',
- 'kv' => 'key_value',
- 'elements' => 'options_elements',
-}, '... got the right provides mapping');
+is_deeply($options->handles, {
+ 'add_options' => 'push',
+ 'remove_last_option' => 'pop',
+ 'remove_first_option' => 'shift',
+ 'insert_options' => 'unshift',
+ 'get_option_at' => 'get',
+ 'set_option_at' => 'set',
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'clear_options' => 'clear',
+ 'splice_options' => 'splice',
+ 'sort_options_in_place' => 'sort_in_place',
+ 'option_accessor' => 'accessor',
+}, '... got the right handles mapping');
is($options->type_constraint->type_parameter, 'Str', '... got the right container type');
is => 'ro',
isa => 'Int',
default => sub { 5 },
- provides => {
+ handles => {
set => 'set',
add => 'add',
sub => 'sub',
div => 'div',
mod => 'mod',
abs => 'abs',
+ inc => [ add => [ 1 ] ],
+ dec => [ sub => [ 1 ] ],
+ odd => [ mod => [ 2 ] ],
+ cut_in_half => [ div => [ 2 ] ],
+
},
- curries => {
- add => {inc => [ 1 ]},
- sub => {dec => [ 1 ]},
- mod => {odd => [ 2 ]},
- div => {cut_in_half => [ 2 ]}
- }
);
}
my $attr = $real->meta->get_attribute('integer');
isa_ok($attr, 'Moose::AttributeHelpers::Number');
-is_deeply($attr->provides, {
+is_deeply($attr->handles, {
set => 'set',
add => 'add',
sub => 'sub',
div => 'div',
mod => 'mod',
abs => 'abs',
-}, '... got the right provides mapping');
+}, '... got the right handles mapping');
isa => 'ArrayRef[Int]',
init_arg => 'options',
default => sub { [] },
- provides => {
- 'count' => 'num_options',
- 'empty' => 'has_options',
- 'map' => 'map_options',
- 'grep' => 'filter_options',
- 'find' => 'find_option',
- 'elements' => 'options',
- 'join' => 'join_options',
- 'get' => 'get_option_at',
- 'first' => 'get_first_option',
- 'last' => 'get_last_option',
- 'sort' => 'sorted_options',
+ handles => {
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'map_options', => 'map',
+ 'filter_options' => 'grep',
+ 'find_option' => 'find',
+ 'options' => 'elements',
+ 'join_options' => 'join',
+ 'get_option_at' => 'get',
+ 'get_first_option' => 'first',
+ 'get_last_option' => 'last',
+ 'sorted_options' => 'sort',
+ 'less_than_five' => [ grep => [ sub { $_ < 5 } ] ],
+ 'up_by_one' => [ map => [ sub { $_ + 1 } ] ],
+ 'dashify' => [ join => [ '-' ] ],
+ 'descending' => [ sort => [ sub { $_[1] <=> $_[0] ] ],
},
- curries => {
- 'grep' => {less_than_five => [ sub { $_ < 5 } ]},
- 'map' => {up_by_one => [ sub { $_ + 1 } ]},
- 'join' => {dashify => [ '-' ]},
- 'sort' => {descending => [ sub { $_[1] <=> $_[0] } ]},
- }
);
has animals => (
is => 'rw',
isa => 'ArrayRef[Str]',
metaclass => 'Collection::List',
- curries => {
- grep => {
- double_length_of => sub {
- my ($self, $body, $arg) = @_;
-
- $body->($self, sub { length($_) == length($arg) * 2 });
- }
- }
+ handles => {
+ double_length_of => [ grep => [ sub {
+ my ($self, $body, $arg) = @_;
+ $body->($self, sub { length($_) == length($arg) * 2 });
+ } ] ],
}
)
}
my $options = $stuff->meta->get_attribute('_options');
isa_ok($options, 'Moose::AttributeHelpers::Collection::List');
-is_deeply($options->provides, {
- 'map' => 'map_options',
- 'grep' => 'filter_options',
- 'find' => 'find_option',
- 'count' => 'num_options',
- 'empty' => 'has_options',
- 'elements' => 'options',
- 'join' => 'join_options',
- 'get' => 'get_option_at',
- 'first' => 'get_first_option',
- 'last' => 'get_last_option',
- 'sort' => 'sorted_options',
-}, '... got the right provides mapping');
+is_deeply($options->handles, {
+ 'num_options' => 'count',
+ 'has_options' => 'empty',
+ 'map_options', => 'map',
+ 'filter_options' => 'grep',
+ 'find_option' => 'find',
+ 'options' => 'elements',
+ 'join_options' => 'join',
+ 'get_option_at' => 'get',
+ 'get_first_option' => 'first',
+ 'get_last_option' => 'last',
+ 'sorted_options' => 'sort',
+ 'less_than_five' => [ grep ],
+ 'up_by_one' => [ map ],
+ 'dashify' => [ join ],
+ 'descending' => [ sort ],
+}, '... got the right handles mapping');
is($options->type_constraint->type_parameter, 'Int', '... got the right container type');