$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
-my @trait_names = qw(Bool Counter Number String Array Hash);
+my @trait_names = qw(Bool Counter Number String Array Hash Code);
for my $trait_name (@trait_names) {
my $trait_class = "Moose::Meta::Attribute::Native::Trait::$trait_name";
--- /dev/null
+package Moose::Meta::Attribute::Trait::Native::Code;
+use Moose::Role;
+use Moose::Meta::Attribute::Trait::Native::MethodProvider::Code;
+
+our $VERSION = '0.87';
+$VERSION = eval $VERSION;
+our $AUTHORITY = 'cpan:STEVAN';
+
+with 'Moose::Meta::Attribute::Trait::Native';
+
+has method_provider => (
+ is => 'ro',
+ isa => 'ClassName',
+ predicate => 'has_method_provider',
+ default => 'Moose::Meta::Attribute::Trait::Native::MethodProvider::Code',
+);
+
+sub _default_is { 'ro' }
+sub _helper_type { 'CodeRef' }
+
+no Moose::Role;
+
+1;
--- /dev/null
+package Moose::Meta::Attribute::Trait::Native::MethodProvider::Code;
+use Moose::Role;
+
+our $VERSION = '0.87';
+$VERSION = eval $VERSION;
+our $AUTHORITY = 'cpan:STEVAN';
+
+sub execute : method {
+ my ( $attr, $reader, $writer ) = @_;
+ return sub { $reader->(@_)->(@_) };
+}
+
+no Moose::Role;
+
+1;
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+{
+ package Thingy;
+ use Moose;
+
+ has callback => (
+ traits => ['Code'],
+ is => 'ro',
+ isa => 'CodeRef',
+ required => 1,
+ handles => { 'invoke_callback' => 'execute' },
+ );
+}
+
+my $i = 0;
+my $thingy = Thingy->new(callback => sub { ++$i });
+
+is($i, 0);
+$thingy->invoke_callback;
+is($i, 1);