{"id":15032758,"url":"https://github.com/ruby/singleton","last_synced_at":"2025-05-16T08:05:44.873Z","repository":{"id":42977439,"uuid":"200772159","full_name":"ruby/singleton","owner":"ruby","description":"The Singleton module implements the Singleton pattern.","archived":false,"fork":false,"pushed_at":"2025-04-29T23:53:35.000Z","size":106,"stargazers_count":29,"open_issues_count":0,"forks_count":8,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-30T00:30:38.615Z","etag":null,"topics":["ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","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,"zenodo":null}},"created_at":"2019-08-06T03:48:37.000Z","updated_at":"2025-04-29T23:53:37.000Z","dependencies_parsed_at":"2023-11-06T10:40:52.987Z","dependency_job_id":"dd211bac-fecc-402a-b2a6-b015d5302154","html_url":"https://github.com/ruby/singleton","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fsingleton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fsingleton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fsingleton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruby%2Fsingleton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruby","download_url":"https://codeload.github.com/ruby/singleton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"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":["ruby"],"created_at":"2024-09-24T20:19:23.319Z","updated_at":"2025-05-16T08:05:39.861Z","avatar_url":"https://github.com/ruby.png","language":"Ruby","readme":"# Singleton\n\nThe Singleton module implements the Singleton pattern.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'singleton'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install singleton\n\n## Usage\n\nTo use Singleton, include the module in your class.\n\n```ruby\nclass Klass\n   include Singleton\n   # ...\nend\n```\n\nThis ensures that only one instance of Klass can be created.\n\n```ruby\na,b = Klass.instance, Klass.instance\n\na == b\n# =\u003e true\n\nKlass.new\n# =\u003e NoMethodError - new is private ...\n```\n\nThe instance is created at upon the first call of Klass.instance().\n\n```ruby\nclass OtherKlass\n  include Singleton\n  # ...\nend\n\nObjectSpace.each_object(OtherKlass){}\n# =\u003e 0\n\nOtherKlass.instance\nObjectSpace.each_object(OtherKlass){}\n# =\u003e 1\n```\n\nThis behavior is preserved under inheritance and cloning.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` 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/ruby/singleton.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Fsingleton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruby%2Fsingleton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruby%2Fsingleton/lists"}