{"id":22981003,"url":"https://github.com/rubyworks/instance","last_synced_at":"2025-08-13T17:33:43.334Z","repository":{"id":13733838,"uuid":"16428151","full_name":"rubyworks/instance","owner":"rubyworks","description":"Slick Object Instance API","archived":false,"fork":false,"pushed_at":"2015-05-29T00:20:27.000Z","size":316,"stargazers_count":37,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-29T12:22:06.495Z","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":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.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}},"created_at":"2014-02-01T04:19:05.000Z","updated_at":"2021-03-08T11:43:23.000Z","dependencies_parsed_at":"2022-09-23T14:56:32.721Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/instance","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Finstance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Finstance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Finstance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Finstance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/instance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229773540,"owners_count":18122031,"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-12-15T01:46:37.109Z","updated_at":"2024-12-15T01:46:37.983Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","readme":"# Instance\n\n## What Is It?\n\nInstance is a *convenient* and *safe* API for accessing and manipulating\nan object's state.\n\n## How Does It Work\n\nInstance adds a method to all objects called `#instance`. It returns\nan `Instance` delegator that provides the full interface to the\nobject's state.\n\nOf course, without implementing this in C, directly in the Ruby source,\nwe  are left to depend on the current provisions Ruby has for accessing\nthe state of an object. So there are some limitations here. However,\nwe implement the Ruby code in such a way as to minimize the downsides\nby caching all the method definitions the Instance class will utilize.\n\n## Usage\n\nLet's use a very simple example class with which to demonstrate usage.\n\n```ruby\n    class Song\n      attr_accessor :title\n      attr_accessor :artist\n      attr_accessor :year\n\n      def initialize(title, artist, year)\n        @title  = title\n        @artist = artist\n        @year   = year\n      end\n    end\n```\n\nNow we can create an instance of Song and work with it's state.\n\n```ruby\n    song = Song.new(\"Paranoid\", \"Black Sabbath\", 1970)\n\n    song.instance.variables\n    # =\u003e [:@title, :@artist, :@year]\n\n    song.instance.get(:title)\n    # =\u003e \"Paranoid\"\n\n    song.instance[:artist]\n    # =\u003e \"Black Sabbath\"\n\n    song.instance.to_h        \n    # =\u003e {:name =\u003e \"Paranoid\", :author =\u003e \"Black Sabbath\", :year =\u003e 1970)\n```\n\nFor a more complete set of usage examples see the [QED](http://rubyworks.github.com/instance/qed.html) documentation.\n\n\n## Copyrights\n\nCopyright \u0026copy; 2014 [Rubyworks](http://rubyworks.github.io)\n\nBSD-2-Clause License\n\nSee [LICENSE.txt](LICENSE.txt) file for license details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Finstance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Finstance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Finstance/lists"}