{"id":17861145,"url":"https://github.com/jonathanstowe/accessorfacade","last_synced_at":"2025-06-17T01:36:44.324Z","repository":{"id":33874067,"uuid":"37583464","full_name":"jonathanstowe/AccessorFacade","owner":"jonathanstowe","description":"A Raku method trait to turn indivdual get/set subroutines into a single read/write object attribute.","archived":false,"fork":false,"pushed_at":"2023-07-02T07:31:18.000Z","size":33,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-07-02T08:34:00.534Z","etag":null,"topics":["accessor","native","raku","trait"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-17T08:46:42.000Z","updated_at":"2023-07-02T08:34:00.535Z","dependencies_parsed_at":"2024-10-28T09:05:47.809Z","dependency_job_id":"ae8af229-e099-40d0-bb73-6649c35b50b7","html_url":"https://github.com/jonathanstowe/AccessorFacade","commit_stats":null,"previous_names":[],"tags_count":12,"template":null,"template_full_name":null,"purl":"pkg:github/jonathanstowe/AccessorFacade","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAccessorFacade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAccessorFacade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAccessorFacade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAccessorFacade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/AccessorFacade/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FAccessorFacade/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260272649,"owners_count":22984361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["accessor","native","raku","trait"],"created_at":"2024-10-28T08:43:03.738Z","updated_at":"2025-06-17T01:36:44.275Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AccessorFacade\n\nA Raku method trait to turn indivdual get/set subroutines into a single read/write object attribute.\n\n![Build Status](https://github.com/jonathanstowe/AccessorFacade/workflows/CI/badge.svg)\n\n## Description\n\nThis module was initially designed to reduce the boiler plate code in\na native library binding that became something like:\n\n```raku\n\n    class Shout is repr('CPointer') {\n\n        sub shout_set_host(Shout, Str) returns int32 is native('libshout') { * }\n        sub shout_get_host(Shout) returns Str is native('libshout') { * }\n\n        method host() is rw {\n            Proxy.new(\n                FETCH =\u003e sub ($) {\n                    shout_get_host(self);\n                },\n                STORE   =\u003e  sub ($, $host is copy ) {\n                    explicitly-manage($host);\n                    shout_set_host(self, $host);\n                }\n            );\n        }\n\n        ...\n\n    }\n\n```\n\nThat is the library API provides a sort of \"object oriented\" mechanism to\nset and get attributes on an opaque object instance that was returned\nby another \"constructor\" function. Because the object is an opaque\nCPointer it can only have subroutines and methods and not private data or\nattributes. The intent of the code is to provide fake \"attributes\" with\nrw methods (which is similar to how public rw attributes are provided.)\n\nThe above code will be reduced with the use of AccessorFacade to:\n\n```raku\n\n    class Shout is repr('CPointer') {\n\n        sub shout_set_host(Shout, Str) returns int32 is native('libshout') { * } \n        sub shout_get_host(Shout) returns Str is native('libshout') { * }\n\n        method host() is rw is accessor-facade(\u0026shout_get_host, \u0026shout_set_host) { }\n\n        ...\n    }\n```\n\nThe named argument style is also supported so the method could be written as:\n\n```raku\n    method host() is rw is accessor-facade(getter =\u003e \u0026shout_get_host, setter =\u003e \u0026shout_set_host) { }\n```\n\nif that proves more suitable.\n\n(The call to explicitly manage is omitted for simplicity but how this is\nachieved is described in the documentation.)  Libshout has a significant\nnumber of these get/set pairs so there is a reduction of typing, copy\nand paste and hopefully programmer error.\n\nWhilst this was designed primarily to work with a fixed native API, it\nis possible that it could be used to provide an OO facade to a plain\nRaku procedural library. The only requirement that there is a getter\nsubroutine that accepts an object as its first argument and returns the\nattribute value and a setter subroutine that accepts the object and the\nvalue to be set (it may return a value to indicate success - how this\nis handled is descibed in the documentation.)\n\n\n## Installation\n\nAssuming you have a working Rakudo installation you should be able to install this with *zef* :\n\n    # From the source directory\n   \n    zef install .\n\n    # Remote installation\n\n    zef install AccessorFacade\n\n## Support\n\nSuggestions/patches are welcomed via github at:\n\nhttps://github.com/jonathanstowe/AccessorFacade/issues\n\n## Licence\n\nThis is free software.\n\nPlease see the [LICENCE](LICENCE) file in the distribution\n\n© Jonathan Stowe 2015 - 2021\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Faccessorfacade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Faccessorfacade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Faccessorfacade/lists"}