{"id":19725316,"url":"https://github.com/bodacious/motion-persistable","last_synced_at":"2025-04-29T23:30:39.612Z","repository":{"id":56884596,"uuid":"20533180","full_name":"Bodacious/motion-persistable","owner":"Bodacious","description":"Cheap and easy attribute persistence for Rubymotion apps","archived":false,"fork":false,"pushed_at":"2017-01-24T14:49:38.000Z","size":8,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-25T19:41:58.005Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/KatanaCode/motion-persistable/","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/Bodacious.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}},"created_at":"2014-06-05T16:46:13.000Z","updated_at":"2021-09-22T10:56:32.000Z","dependencies_parsed_at":"2022-08-20T23:40:36.477Z","dependency_job_id":null,"html_url":"https://github.com/Bodacious/motion-persistable","commit_stats":null,"previous_names":["katanacode/motion-persistable"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fmotion-persistable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fmotion-persistable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fmotion-persistable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bodacious%2Fmotion-persistable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bodacious","download_url":"https://codeload.github.com/Bodacious/motion-persistable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251599702,"owners_count":21615571,"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-11-11T23:29:22.724Z","updated_at":"2025-04-29T23:30:36.886Z","avatar_url":"https://github.com/Bodacious.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Motion::Persistable\n\n## Persistable attributes for Rubymotion classes\n\nA nice wrapper around Bubble-wrap's App::Persistence module that adds class macros for attributes that are persistable\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'motion-persistable'\n\nAnd then execute:\n\n    $ bundle\n\n\nOr install it yourself with:\n\n    $ gem install motion-persistable\n\n...add this line to your application's Rakefile:\n    \n    Bundler.require # this should already be there\n    require 'motion-persistable'\n\n\n## Usage\n\nInclude the module **Motion::Persistable** in any class that you want persistable attributes\n\n### Persistable Instance Methods\n\n    class User\n  \n      include Motion::Persistable\n  \n      # Define this in your model to use your own key, otherise it will try and call \n      # name() on the instance by default\n      def persistence_key\n        \"User\"\n      end\n      \n      # This will persist the user's email under the key: \"User.bodacious.email\" (where the\n      # user's username was bodacious)\n      attr_persisted :email, '', :username\n\n      # This will set an attribute called age, with a default value of 16.\n      # When a new value is set, the block is called, in this case it's recorded on TestFlight\n      attr_persisted :age, 16, :username do |value|\n        testflight_checkpoint(\"Set new age value\", age: value)\n      end\n  \n      class \u003c\u003c self \n        include Motion::Persistable # for class methods\n\n        # This will set a class attribute User.count with a default value of 0\n        attr_persisted :count, 0\n      end\n  \n    end\n  \n## Gotchas\n\n* Dont' set class attributes called `name()` without providing a `key()`. The `name()` method defined on instances of `Class` is used as a default key prefix when no `key()` method has been defined. This is handy because it provides key names such as `\"User.login_count\"` but will cause an infinite loop if no `key()` is defined as an alternative.\n\n## Considerations\n\nThe obvious drawback with this current approach is that instances require unique keys.\nFor the project this was designed for, this wasn't an issue but if your instances don't \nalready have some sort of unique identifier then this gem might not be best for you.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodacious%2Fmotion-persistable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbodacious%2Fmotion-persistable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbodacious%2Fmotion-persistable/lists"}