{"id":18026806,"url":"https://github.com/yegor256/others","last_synced_at":"2025-10-18T17:28:21.649Z","repository":{"id":245798020,"uuid":"819232266","full_name":"yegor256/others","owner":"yegor256","description":"Catch all missing methods by a single proc, similar to what method_missing() is doing","archived":false,"fork":false,"pushed_at":"2024-09-17T07:44:43.000Z","size":32,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-17T13:04:46.101Z","etag":null,"topics":["ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/others","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/yegor256.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-24T05:28:35.000Z","updated_at":"2024-09-16T10:55:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"0cd07cb3-4913-4834-b0ab-c0dd1b882101","html_url":"https://github.com/yegor256/others","commit_stats":null,"previous_names":["yegor256/others"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fothers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fothers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fothers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yegor256%2Fothers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yegor256","download_url":"https://codeload.github.com/yegor256/others/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247240652,"owners_count":20906859,"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","ruby-gem"],"created_at":"2024-10-30T08:08:07.313Z","updated_at":"2025-10-18T17:28:21.622Z","avatar_url":"https://github.com/yegor256.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Functions as Objects, in Ruby\n\n[![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/others)](https://www.rultor.com/p/yegor256/others)\n[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)\n\n[![rake](https://github.com/yegor256/others/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/others/actions/workflows/rake.yml)\n[![PDD status](https://www.0pdd.com/svg?name=yegor256/others)](https://www.0pdd.com/p?name=yegor256/others)\n[![Gem Version](https://badge.fury.io/rb/others.svg)](https://badge.fury.io/rb/others)\n[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/others.svg)](https://codecov.io/github/yegor256/others?branch=master)\n[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/others/master/frames)\n[![Hits-of-Code](https://hitsofcode.com/github/yegor256/others)](https://hitsofcode.com/view/github/yegor256/others)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/others/blob/master/LICENSE.txt)\n\nLet's say you need an object that consists of a single function:\n\n```ruby\nrequire 'others'\nx = others(foo: 42) do |*args|\n  @foo + args[1]\nend\nassert(x.bar(10) == 52)\n```\n\nYou can also do this in a class:\n\n```ruby\nrequire 'others'\nclass Foo\n  def foo(a)\n    a + 1\n  end\n  others do |*args|\n    args[1] + 10\n  end\nend\nx = Foo.new\nassert(x.foo(10) == 11)\nassert(x.bar(42) == 52)\n```\n\nFor example, you can create a decorator that\nintercepts all method calls and logs them:\n\n```ruby\nlogger = others(base: original_object) do |*args, \u0026block|\n  puts \"Method #{args[0]} called with #{args[1..-1].inspect}\"\n  @base.__send__(*args, \u0026block)\nend\n```\n\nIt also supports forwarding blocks:\n\n```ruby\nx = others(foo: 42) do |*args|\n  @foo + args.last.call # this is the block, as the last argument\nend\nputs x.bar { 12 }  # =\u003e 54\n```\n\n## How to contribute\n\nRead\n[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).\nMake sure your build is green before you contribute\nyour pull request. You will need to have\n[Ruby](https://www.ruby-lang.org/en/) 3.2+ and\n[Bundler](https://bundler.io/) installed. Then:\n\n```bash\nbundle update\nbundle exec rake\n```\n\nIf it's clean and you don't see any error messages, submit your pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fothers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyegor256%2Fothers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyegor256%2Fothers/lists"}