{
    "mode": "perldoc",
    "parameter": "Moose::Meta::Attribute::Native::Trait::Code",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Moose%3A%3AMeta%3A%3AAttribute%3A%3ANative%3A%3ATrait%3A%3ACode/json",
    "generated": "2026-06-13T06:35:47Z",
    "synopsis": "package Foo;\nuse Moose;\nhas 'callback' => (\ntraits  => ['Code'],\nis      => 'ro',\nisa     => 'CodeRef',\ndefault => sub {\nsub { print \"called\" }\n},\nhandles => {\ncall => 'execute',\n},\n);\nmy $foo = Foo->new;\n$foo->call;    # prints \"called\"",
    "sections": {
        "NAME": {
            "content": "Moose::Meta::Attribute::Native::Trait::Code - Helper trait for CodeRef attributes\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.2200\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package Foo;\nuse Moose;\n\nhas 'callback' => (\ntraits  => ['Code'],\nis      => 'ro',\nisa     => 'CodeRef',\ndefault => sub {\nsub { print \"called\" }\n},\nhandles => {\ncall => 'execute',\n},\n);\n\nmy $foo = Foo->new;\n$foo->call;    # prints \"called\"\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This trait provides native delegation methods for code references.\n",
            "subsections": []
        },
        "DEFAULT TYPE": {
            "content": "If you don't provide an \"isa\" value for your attribute, it will default to \"CodeRef\".\n",
            "subsections": []
        },
        "PROVIDED METHODS": {
            "content": "*   execute(@args)\n\nCalls the coderef with the given args.\n\n*   executemethod(@args)\n\nCalls the coderef with the instance as invocant and given args.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "See \"BUGS\" in Moose for details on reporting bugs.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "*   Stevan Little <stevan@cpan.org>\n\n*   Dave Rolsky <autarch@urth.org>\n\n*   Jesse Luehrs <doy@cpan.org>\n\n*   Shawn M Moore <sartak@cpan.org>\n\n*   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>\n\n*   Karen Etheridge <ether@cpan.org>\n\n*   Florian Ragwitz <rafl@debian.org>\n\n*   Hans Dieter Pearcey <hdp@cpan.org>\n\n*   Chris Prather <chris@prather.org>\n\n*   Matt S Trout <mstrout@cpan.org>\n",
            "subsections": []
        },
        "COPYRIGHT AND LICENSE": {
            "content": "This software is copyright (c) 2006 by Infinity Interactive, Inc.\n\nThis is free software; you can redistribute it and/or modify it under the same terms as the Perl\n5 programming language system itself.\n",
            "subsections": []
        }
    },
    "summary": "Moose::Meta::Attribute::Native::Trait::Code - Helper trait for CodeRef attributes",
    "flags": [],
    "examples": [],
    "see_also": []
}