{"id":16102352,"url":"https://github.com/sshaw/property_string","last_synced_at":"2026-01-04T09:04:35.591Z","repository":{"id":210647656,"uuid":"726334537","full_name":"sshaw/property_string","owner":"sshaw","description":"Use Java-style property notation to execute method call chains on an object","archived":false,"fork":false,"pushed_at":"2024-07-24T05:34:28.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-21T06:47:11.877Z","etag":null,"topics":["attributes","java","method-chaining","properties","property-wrapper","ruby"],"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/sshaw.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2023-12-02T04:37:42.000Z","updated_at":"2024-07-24T05:34:31.000Z","dependencies_parsed_at":"2024-07-24T07:11:55.062Z","dependency_job_id":null,"html_url":"https://github.com/sshaw/property_string","commit_stats":null,"previous_names":["sshaw/property_string"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fproperty_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fproperty_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fproperty_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Fproperty_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshaw","download_url":"https://codeload.github.com/sshaw/property_string/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244890091,"owners_count":20527031,"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":["attributes","java","method-chaining","properties","property-wrapper","ruby"],"created_at":"2024-10-09T18:53:36.867Z","updated_at":"2026-01-04T09:04:35.530Z","avatar_url":"https://github.com/sshaw.png","language":"Ruby","readme":"# PropertyString\n\n![PropertyString CI Status](https://github.com/sshaw/property_string/workflows/CI/badge.svg \"PropertyString CI Status\")\n\nUse Java-style property notation to execute method call chains on an object.\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    bundle add property_string\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    gem install property_string\n\n## Usage\n\n```rb\n# Object call chain\nproduct.company.name            # bar\n\nps = PropertyString.new(product)\nps[\"company.name\"]              # bar\n\n# Object call chain with Array-like object\nuser.posts[0].replied_to.name   # sshaw\n\nps = PropertyString.new(user)\nps[\"posts.0.replied_to.name\"]       # sshaw\n\n# Method does not exist\nps = PropertyString.new(product)\nps[\"company.does_not_exist!\"] # NoMethodError\n\n# Can work with a Hash\nh.dig(:some, \"nested\", :hash)   # foo\n\nps = PropertyString.new(h)\nps[\"some.nested.hash\"]\n\n# Or an Array\na[0][0][0]\n\nps = PropertyString.new(a)\nps[\"0.0.0\"]\n\n# Fetching\nps.fetch(\"posts.9999\", \"your default\")\nps.fetch(\"posts.9999\") { |key| \"some_default_for_#{key}\" }\n```\n\n### Ignore `NoMethodError` for Unknown Properties\n\n```rb\nps = PropertyString.new(product, :raise_if_method_missing =\u003e false)\nps[\"company.does_not_exist!\"] # nil\n```\n\n### Restrict Methods That Can Be Called\n\n```rb\nps = PropertyString.new(product, :whitelist =\u003e { Product =\u003e %w[company], Company =\u003e %w[name] })\nps[\"id\"] # PropertyString::MethodNotAllowed\nps[\"company.id\"] # PropertyString::MethodNotAllowed\n```\n\nCurrently does not work when a superclass is whitelisted but trivial to add.\n\n## See Also\n\n- [PropertyHash](https://github.com/sshaw/property_hash) - Access a nested Ruby Hash using Java-style properties as keys.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sshaw/property_string.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fproperty_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshaw%2Fproperty_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fproperty_string/lists"}