{
    "mode": "info",
    "parameter": "Moose::Cookbook::Extending::Mooseish_MooseSugar",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/info/Moose%3A%3ACookbook%3A%3AExtending%3A%3AMooseish_MooseSugar/json",
    "generated": "2026-07-05T16:00:02Z",
    "synopsis": "package MyApp::Mooseish;\nuse Moose::Exporter;\nMoose::Exporter->setupimportmethods(\nwithmeta       => ['hastable'],\nclassmetaroles => {\nclass => ['MyApp::Meta::Class::Trait::HasTable'],\n},\n);\nsub hastable {\nmy $meta = shift;\n$meta->table(shift);\n}\npackage MyApp::Meta::Class::Trait::HasTable;\nuse Moose::Role;\nhas table => (\nis  => 'rw',\nisa => 'Str',\n);",
    "sections": {
        "Moose::Cookbook::ExtenUserMoose::Cookbook::Extending::MooseishMooseSugar(3pm)": {
            "content": "",
            "subsections": []
        },
        "NAME": {
            "content": "Moose::Cookbook::Extending::MooseishMooseSugar - Acting like Moose.pm\nand providing sugar Moose-style\n",
            "subsections": []
        },
        "VERSION": {
            "content": "version 2.2200\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package MyApp::Mooseish;\n\nuse Moose::Exporter;\n\nMoose::Exporter->setupimportmethods(\nwithmeta       => ['hastable'],\nclassmetaroles => {\nclass => ['MyApp::Meta::Class::Trait::HasTable'],\n},\n);\n\nsub hastable {\nmy $meta = shift;\n$meta->table(shift);\n}\n\npackage MyApp::Meta::Class::Trait::HasTable;\nuse Moose::Role;\n\nhas table => (\nis  => 'rw',\nisa => 'Str',\n);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This recipe expands on the use of Moose::Exporter we saw in\nMoose::Cookbook::Extending::ExtensionOverview and the class metaclass\ntrait we saw in Moose::Cookbook::Meta::TableMetaclassTrait. In this\nexample we provide our own metaclass trait, and we also export a\n\"hastable\" sugar function.\n\nThe \"withmeta\" parameter specifies a list of functions that should be\nwrapped before exporting. The wrapper simply ensures that the importing\npackage's appropriate metaclass object is the first argument to the\nfunction, so we can do \"my$meta=shift;\".\n\nSee the Moose::Exporter docs for more details on its API.\n\nUSING MyApp::Mooseish\nThe purpose of all this code is to provide a Moose-like interface.\nHere's what it would look like in actual use:\n\npackage MyApp::User;\n\nuse namespace::autoclean;\n\nuse Moose;\nuse MyApp::Mooseish;\n\nhastable 'User';\n\nhas 'username' => ( is => 'ro' );\nhas 'password' => ( is => 'ro' );\n\nsub login { ... }\n",
            "subsections": []
        },
        "CONCLUSION": {
            "content": "Providing sugar functions can make your extension look much more Moose-\nish. See Fey::ORM for a more extensive example.\n",
            "subsections": []
        },
        "AUTHORS": {
            "content": "o   Stevan Little <stevan@cpan.org>\n\no   Dave Rolsky <autarch@urth.org>\n\no   Jesse Luehrs <doy@cpan.org>\n\no   Shawn M Moore <sartak@cpan.org>\n\no    ' (Yuval Kogman) <nothingmuch@woobling.org>\n\no   Karen Etheridge <ether@cpan.org>\n\no   Florian Ragwitz <rafl@debian.org>\n\no   Hans Dieter Pearcey <hdp@cpan.org>\n\no   Chris Prather <chris@prather.org>\n\no   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\nthe same terms as the Perl 5 programming language system itself.\n\nperl v5.34.0              Moose::Cookbook::Extending::MooseishMooseSugar(3pm)",
            "subsections": []
        }
    },
    "summary": "Moose::Cookbook::Extending::MooseishMooseSugar - Acting like Moose.pm and providing sugar Moose-style",
    "flags": [],
    "examples": [],
    "see_also": []
}