{"id":20269905,"url":"https://github.com/teliosdev/settingable","last_synced_at":"2025-06-21T12:39:13.613Z","repository":{"id":34220576,"uuid":"38081850","full_name":"teliosdev/settingable","owner":"teliosdev","description":null,"archived":false,"fork":false,"pushed_at":"2015-08-04T06:50:51.000Z","size":152,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-03T20:09:26.349Z","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":"mozilla/devroadshow2017","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teliosdev.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}},"created_at":"2015-06-26T00:34:20.000Z","updated_at":"2015-08-04T05:10:08.000Z","dependencies_parsed_at":"2022-09-04T11:12:23.439Z","dependency_job_id":null,"html_url":"https://github.com/teliosdev/settingable","commit_stats":null,"previous_names":["medcat/settingable"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/teliosdev/settingable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fsettingable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fsettingable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fsettingable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fsettingable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teliosdev","download_url":"https://codeload.github.com/teliosdev/settingable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fsettingable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261126205,"owners_count":23113289,"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-14T12:27:58.356Z","updated_at":"2025-06-21T12:39:08.575Z","avatar_url":"https://github.com/teliosdev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# settingable [![Build Status](https://travis-ci.org/medcat/settingable.svg)](https://travis-ci.org/medcat/settingable)\n\n* [Homepage](https://rubygems.org/gems/settingable)\n* [Documentation](http://rubydoc.info/gems/settingable/frames)\n* [Email](mailto:me@medcat.me)\n\n## Install\n\n    $ gem install settingable\n\n## Description\n\nA Settings module for your application.  Its job is to make handling\nuser-definable settings easy for you, so you can focus on the more\nimportant parts of your library.  The main component of it is the\n`Settingable::Settings` module.  Just include that in a class, and\nyou're good to go.\n\n```Ruby\nmodule MyLibrary\n  class Settings\n    include Settingable::Settings\nend\n```\n\nThe `Settings` module provides a few methods.  First, it defines the\n`.instance` class method.  This returns a single instance upon\nrepeated invocation, like the `Singleton` module.  Then, it defines\nthe `.configure` method.  This is used to (*ahem*) configure the\nsettings.  It both yields itself and runs it in its context, so you\nmay configure it however you like.  It also forwards the methods\n`.[]`, `.[]=`, and `.fetch` on to the actual instance itself as well.\n\nThe instance forwards the `#[]`, `#[]=`, `#fetch`, and `#key?` method\non to the `Settingable::Hash` powering the settings (see the\ndocumentation for more).  The instance can also accept any other\nmethods.  If the method ends in an equal sign (i.e. a setter method),\nit is forwarded to `#[]=`; otherwise, it is forwarded to `#[]`.\n\nHere's a few examples.\n\n```Ruby\nMyLibrary::Settings.configure do |config|\n  # These two are the same.\n  config.value = 2\n  config[:value] = 2\nend\n\n# These all are the same, and return the same value.\nMyLibrary::Settings.value\nMyLibrary::Settings[:value]\nMyLibrary::Settings[\"value\"]\nMyLibrary::Settings.instance.value\nMyLibrary::Settings.instance[:value]\nMyLibrary::Settings.instance[\"value\"]\n```\n\nIf you attempt to access a setting value that isn't defined, even if\nyou use the regular accessor (`#[]`), a `KeyError` will be raised.\nSo, the module provides a `.default_settings` method, for you to\nprovide default values for the settings.\n\n```Ruby\nmodule MyLibrary\n  class Settings\n    include Settingable::Settings\n\n    default_settings foo: \"bar\"\n  end\nend\n```\n\nNow, check it out.\n\n```Ruby\nMyLibrary::Settings[:foo] # =\u003e \"bar\"\nMyLibrary::Settings[:bar] # ! KeyError\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fsettingable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteliosdev%2Fsettingable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fsettingable/lists"}