{"id":15554168,"url":"https://github.com/gangelo/protectedconstructor","last_synced_at":"2026-02-08T05:02:18.653Z","repository":{"id":9392759,"uuid":"11255619","full_name":"gangelo/ProtectedConstructor","owner":"gangelo","description":"Provides a module that may be included in a Ruby class, that protects the constructor; good for enforcing instantiation of classes using, for instance, a class factory. The code itself is not mine, I just wrapped it in a gem and provided the examples; sorry, I don't remember the origin of the code to give credit. :S","archived":false,"fork":false,"pushed_at":"2024-11-04T07:00:45.000Z","size":56,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T13:05:00.817Z","etag":null,"topics":["constructor","gems","rails","ruby","ruby-gem","ruby-gems","ruby-on-rails"],"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/gangelo.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":"2013-07-08T13:57:07.000Z","updated_at":"2024-08-07T11:46:37.000Z","dependencies_parsed_at":"2024-05-06T07:30:25.273Z","dependency_job_id":"51e95ea5-c081-44dc-90cd-5227f3a233c8","html_url":"https://github.com/gangelo/ProtectedConstructor","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":"0.033333333333333326","last_synced_commit":"e4f4a1ee91ca08b163703d736bab99f2d02c3a1e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2FProtectedConstructor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2FProtectedConstructor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2FProtectedConstructor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gangelo%2FProtectedConstructor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gangelo","download_url":"https://codeload.github.com/gangelo/ProtectedConstructor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883221,"owners_count":21819159,"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":["constructor","gems","rails","ruby","ruby-gem","ruby-gems","ruby-on-rails"],"created_at":"2024-10-02T14:51:01.170Z","updated_at":"2026-02-08T05:02:18.645Z","avatar_url":"https://github.com/gangelo.png","language":"Ruby","readme":"[![Ruby](https://github.com/gangelo/ProtectedConstructor/actions/workflows/ruby.yml/badge.svg)](https://github.com/gangelo/ProtectedConstructor/actions/workflows/ruby.yml)\n[![GitHub version](http://badge.fury.io/gh/gangelo%2FProtectedConstructor.svg?refresh=9)](http://badge.fury.io/gh/gangelo%2FProtectedConstructor.svg)\n[![Gem Version](https://badge.fury.io/rb/ProtectedConstructor.svg?refresh=9)](https://badge.fury.io/rb/ProtectedConstructor.svg)\n[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/gems/ProtectedConstructor/)\n[![Report Issues](https://img.shields.io/badge/report-issues-red.svg)](https://github.com/gangelo/ProtectedConstructor/issues)\n[![License](http://img.shields.io/badge/license-MIT-yellowgreen.svg)](#license)\n\n# ProtectedConstructor\nProvides a module that may be included in a Ruby class, that protects the constructor; good for enforcing\ninstantiation of classes using, for instance, a class factory. The code itself is not mine, I just wrapped it\nin a gem and provided the examples; sorry, I don't remember the origin of the code to give credit.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'ProtectedConstructor'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ProtectedConstructor\n\n## Usage\n\n    require 'protected_constructor'\n\n    class Klass\n      include ProtectedConstructor\n\n      def initialize\n      end\n    end\n\n    module KlassFactory\n      class \u003c\u003c self\n        public\n        def create\n          Klass.send(:new)\n        end\n      end\n    end\n\n    # Constructor is protected.\n    klass = Klass.new # NoMethodError\n\n    # Example using factory...\n    klass = KlassFactory::create # works\n    klass.nil?  # false\n    klass.is_a?(Klass) # true\n\n    # Example just using  #send...\n    klass = Klass.send(:new)  # works\n    klass.nil?  # false\n    klass.is_a?(Klass)  # true\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","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgangelo%2Fprotectedconstructor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgangelo%2Fprotectedconstructor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgangelo%2Fprotectedconstructor/lists"}