{"id":15484771,"url":"https://github.com/emcousin/activerecord-deepstore","last_synced_at":"2025-10-08T19:00:17.514Z","repository":{"id":234741050,"uuid":"789181344","full_name":"EmCousin/activerecord-deepstore","owner":"EmCousin","description":"ActiveRecord-Deepstore adds powerful functionality to ActiveRecord models for handling deeply nested data structures within database columns. Simplify storing, accessing, and managing complex nested data in your Rails applications with ease.","archived":false,"fork":false,"pushed_at":"2024-11-14T16:40:07.000Z","size":45,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T14:13:21.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/EmCousin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-04-19T21:42:58.000Z","updated_at":"2024-11-14T16:40:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd425325-71bb-4abc-b143-98da03b590a9","html_url":"https://github.com/EmCousin/activerecord-deepstore","commit_stats":null,"previous_names":["emcousin/activerecord-deepstore"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Factiverecord-deepstore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Factiverecord-deepstore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Factiverecord-deepstore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmCousin%2Factiverecord-deepstore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmCousin","download_url":"https://codeload.github.com/EmCousin/activerecord-deepstore/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232388932,"owners_count":18515734,"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":[],"created_at":"2024-10-02T05:50:16.593Z","updated_at":"2025-10-08T19:00:11.994Z","avatar_url":"https://github.com/EmCousin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ActiveRecord-Deepstore\n\nActiveRecord-Deepstore is a Ruby gem that extends ActiveRecord models with additional functionality for handling deeply nested data structures within a database column. It simplifies storing, accessing, and managing complex nested data in your Rails applications.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activerecord-deepstore'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install activerecord-deepstore\n```\n\n## Usage\n\nTo use ActiveRecord-Deepstore in your Rails application, include it in your ActiveRecord models:\n\n```ruby\nclass MyModel \u003c ActiveRecord::Base\n  extend ActiveRecord::Deepstore\nend\n```\n\nOnce included, your models gain access to methods for storing and accessing deeply nested data within database columns.\n\n### Example\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  extend ActiveRecord::Deepstore\n\n  deep_store :settings, {\n    notifications: {\n      posts: { push: true, email: true },\n      comments: { push: true, email: false }\n    }\n  }\nend\n```\n\nThis implementation provides with an accessor for every level of the provider hash:\n\n```ruby\nuser.notifications_settings # =\u003e { posts: { push: true, email: true }, comments: { push: true, email: false } }\nuser.posts_notifications_settings # =\u003e { push: true, email: true }\nuser.push_posts_notifications_settings # =\u003e true\nuser.email_posts_notifications_settings # =\u003e true\nuser.comments_notifications_settings # =\u003e { push: true, email: false }\nuser.push_comments_notifications_settings # =\u003e true\nuser.email_comments_notifications_settings # =\u003e false\n```\n\nYou can list all the generated accessors by calling `deep_stored_accessors` on the model `User`:\n\n```ruby\nUser.deep_stored_accessors\n# =\u003e [\"notifications_settings\", \"posts_notifications_settings\", \"push_posts_notifications_settings\", [...], \"email_comments_notifications_settings\"]\n```\n\n#### Automatic typecasting\n\nWriter methods automatically cast the value to the type the default values belong to. For example:\n\n```ruby\nuser.push_comments_notifications_settings = \"1\" # =\u003e \"1\"\nuser.push_comments_notifications_settings # =\u003e true\nuser.push_comments_notifications_settings = \"0\" # =\u003e \"0\"\nuser.push_comments_notifications_settings # =\u003e false\n```\n\n#### Tracking value changes\n\nDirty attributes are implemented for every accessor. For example:\n\n```ruby\nuser.push_comments_notifications_settings # =\u003e false\nuser.push_comments_notifications_settings = true # =\u003e true\nuser.push_comments_notifications_settings_was # =\u003e false\nuser.push_comments_notifications_settings_changes # =\u003e { false =\u003e true }\nuser.push_comments_notifications_settings_changed? # =\u003e true\n```\n\n#### Accessing default values\n\nYou can access the default value of every accessor at anytime by calling the associated `default_#{accessor_name}` method:\n\n```ruby\nuser.push_comments_notifications_settings # =\u003e false\nuser.update! push_comments_notifications_settings: true\nuser.push_comments_notifications_settings # =\u003e true\nuser.default_push_comments_notifications_settings #=\u003e false\n```\n\n#### Resetting to default values\n\nYou can reset every accessor to its default value  at anytime by calling the associated `reset_#{accessor_name}` method:\n\n```ruby\n# When the changes are not persisted\nuser.push_comments_notifications_settings # =\u003e false\nuser.push_comments_notifications_settings = true\nuser.reset_push_comments_notifications_settings\nuser.push_comments_notifications_settings # =\u003e false\n\n# When the changes are persisted\nuser.update! push_comments_notifications_settings: true\nuser.push_comments_notifications_settings # =\u003e true\nuser.reset_push_comments_notifications_settings!\nuser.reload.push_comments_notifications_settings # =\u003e false\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [https://github.com/EmCousin/activerecord-deepstore](https://github.com/EmCousin/activerecord-deepstore).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcousin%2Factiverecord-deepstore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femcousin%2Factiverecord-deepstore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femcousin%2Factiverecord-deepstore/lists"}