{"id":19648593,"url":"https://github.com/bestpractical/object-declare","last_synced_at":"2026-03-04T13:31:50.335Z","repository":{"id":543892,"uuid":"173883","full_name":"bestpractical/object-declare","owner":"bestpractical","description":null,"archived":false,"fork":false,"pushed_at":"2009-04-12T05:06:20.000Z","size":132,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-27T00:45:51.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://search.cpan.org/dist/Object-Declare","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestpractical.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-04-12T05:05:43.000Z","updated_at":"2019-08-13T14:17:16.000Z","dependencies_parsed_at":"2022-07-07T23:20:45.328Z","dependency_job_id":null,"html_url":"https://github.com/bestpractical/object-declare","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bestpractical/object-declare","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Fobject-declare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Fobject-declare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Fobject-declare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Fobject-declare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestpractical","download_url":"https://codeload.github.com/bestpractical/object-declare/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestpractical%2Fobject-declare/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30081426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T14:49:07.508Z","updated_at":"2026-03-04T13:31:50.311Z","avatar_url":"https://github.com/bestpractical.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    Object::Declare - Declarative object constructor\n\nSYNOPSIS\n        use Object::Declare ['MyApp::Column', 'MyApp::Param'];\n\n        my %objects = declare {\n\n        param foo =\u003e\n           !is global,\n            is immutable,\n            valid_values are qw( more values );\n\n        column bar =\u003e\n            field1 is 'value',\n            field2 is 'some_other_value',\n            sub_params are param( is happy ), param ( is sad );\n\n        };\n\n        print $objects{foo}; # a MyApp::Param object\n        print $objects{bar}; # a MyApp::Column object\n\n        # Assuming that MyApp::Column::new simply blesses into a hash...\n        print $objects{bar}{sub_params}[0]; # a MyApp::Param object\n        print $objects{bar}{sub_params}[1]; # a MyApp::Param object\n\nDESCRIPTION\n    This module exports one function, \"declare\", for building named objects\n    with a declarative syntax, similar to how Jifty::DBI::Schema defines its\n    columns.\n\n    In list context, \"declare\" returns a list of name/object pairs in the\n    order of declaration (allowing duplicates), suitable for putting into a\n    hash. In scalar context, \"declare\" returns a hash reference.\n\n    Using a flexible \"import\" interface, one can change exported helper\n    functions names (*declarator*), words to link labels and values together\n    (*copula*), and the table of named classes to declare (*mapping*):\n\n        use Object::Declare\n            declarator  =\u003e ['declare'],     # list of declarators\n            copula      =\u003e {                # list of words, or a map\n                is  =\u003e '',                  #  from copula to label prefixes,\n                are =\u003e '',                  #  or to callback that e.g. turns\n                has =\u003e sub { has =\u003e @_ },   #  \"has X\" to \"has is X\" and\n                                            #  \"X has 1\" to \"has is [X =\u003e 1]\"\n            },\n            aliases     =\u003e {                # list of label aliases:\n                more =\u003e 'less',             #  turns \"is more\" into \"is less\"\n                                            #  and \"more is 1\" into \"less is 1\"\n            },\n            mapping     =\u003e {\n                column =\u003e 'MyApp::Column',  # class name to call -\u003enew to\n                param  =\u003e sub {             # arbitrary coderef also works\n                    bless(\\@_, 'MyApp::Param');\n                },\n            };\n\n    After the declarator block finishes execution, all helper functions are\n    removed from the package. Same-named functions (such as \u0026is and \u0026are)\n    that existed before the declarator's execution are restored correctly.\n\nNOTES\n    If you export the declarator to another package via @EXPORT, be sure to\n    export all mapping keys as well. For example, this will work for the\n    example above:\n\n        our @EXPORT = qw( declare column param );\n\n    But this will not:\n\n        our @EXPORT = qw( declare );\n\n    The copula are not turned into functions, so there is no need to export\n    them.\n\nAUTHORS\n    Audrey Tang \u003ccpan@audreyt.org\u003e\n\nCOPYRIGHT\n    Copyright 2006, 2007 by Audrey Tang \u003ccpan@audreyt.org\u003e.\n\n    This software is released under the MIT license cited below.\n\n  The \"MIT\" License\n    Permission is hereby granted, free of charge, to any person obtaining a\n    copy of this software and associated documentation files (the\n    \"Software\"), to deal in the Software without restriction, including\n    without limitation the rights to use, copy, modify, merge, publish,\n    distribute, sublicense, and/or sell copies of the Software, and to\n    permit persons to whom the Software is furnished to do so, subject to\n    the following conditions:\n\n    The above copyright notice and this permission notice shall be included\n    in all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestpractical%2Fobject-declare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestpractical%2Fobject-declare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestpractical%2Fobject-declare/lists"}