{"id":15683772,"url":"https://github.com/estepnv/property-accessor","last_synced_at":"2025-05-07T14:45:44.832Z","repository":{"id":56888977,"uuid":"246360399","full_name":"estepnv/property-accessor","owner":"estepnv","description":"Ruby syntax sugar for C# style property accessor definition","archived":false,"fork":false,"pushed_at":"2020-03-11T20:08:27.000Z","size":17,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T11:11:07.682Z","etag":null,"topics":["accessor","attributes","getters","properties","property","rails","ruby","setters"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/estepnv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-10T17:06:43.000Z","updated_at":"2025-03-06T10:58:29.000Z","dependencies_parsed_at":"2022-08-20T23:40:27.017Z","dependency_job_id":null,"html_url":"https://github.com/estepnv/property-accessor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estepnv%2Fproperty-accessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estepnv%2Fproperty-accessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estepnv%2Fproperty-accessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/estepnv%2Fproperty-accessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/estepnv","download_url":"https://codeload.github.com/estepnv/property-accessor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252898268,"owners_count":21821582,"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","attributes","getters","properties","property","rails","ruby","setters"],"created_at":"2024-10-03T17:08:34.087Z","updated_at":"2025-05-07T14:45:44.780Z","avatar_url":"https://github.com/estepnv.png","language":"Ruby","readme":"# property_accessor\n\nRuby syntax sugar for C# style property accessor definition\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'property-accessor'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install property-accessor\n\n## Usage\n\nThere are two ways of using property accessor.\n\nYou can inject `property` singleton method directly to `Class` object during your app initialization.\n\n```ruby\nPropertyAccessor::Mixin.inject!\n```\n\nOr you can manually extend your class with `PropertyAccessor` module\n\n```ruby\nrequire 'date'\n\nclass Person\n  extend PropertyAccessor\n\n  property(:first_name)   { get { @name.upcase }; set(:family_name) { |val| @name = val } }\n  property(:last_name)    { get; set }\n  property(:full_name)    { get { \"#{first_name} #{last_name}\" } }\n  property(:birth_date)   { get; set { |val| @birth_date = Date.parse(val.to_s) } }\n  property(:age)          { get { (Time.now - birth_date.to_time).to_i / 60 / 60 / 24 / 365 } }\n  property(:confidential) { private get; public set; }\n  property(:middle_name)  { get(:get_middle_name); set(:set_middle_name); }\n  property(:meta)         { default { {} }; get }\nend\n\np = Person.new\np.first_name = 'john'\np.last_name = 'doe'\np.full_name\n# =\u003e 'JOHN doe'\np.birth_date = \"1992-04-12\"\np.age\n# =\u003e 27\np.meta\n# =\u003e {}\n```\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/estepnv/property-accessor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/estepnv/property-accessor/blob/master/CODE_OF_CONDUCT.md).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the property_accessor project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/estepnv/property-accessor/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festepnv%2Fproperty-accessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festepnv%2Fproperty-accessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festepnv%2Fproperty-accessor/lists"}