{"id":29193122,"url":"https://github.com/dbongo/callable-mixin","last_synced_at":"2026-04-09T10:33:47.417Z","repository":{"id":300060858,"uuid":"1005055141","full_name":"dbongo/callable-mixin","owner":"dbongo","description":"Tiny Ruby mix-in that adds a .call class method to any service object","archived":false,"fork":false,"pushed_at":"2025-06-20T19:19:18.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-20T19:36:56.629Z","etag":null,"topics":["call","callable","gem","mixin","ruby","service-object"],"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/dbongo.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,"zenodo":null}},"created_at":"2025-06-19T15:38:00.000Z","updated_at":"2025-06-20T18:06:03.000Z","dependencies_parsed_at":"2025-06-20T19:37:00.848Z","dependency_job_id":"7782f441-8049-44ca-a06e-4ab14d004d54","html_url":"https://github.com/dbongo/callable-mixin","commit_stats":null,"previous_names":["dbongo/callable","dbongo/callable-mixin"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dbongo/callable-mixin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbongo%2Fcallable-mixin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbongo%2Fcallable-mixin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbongo%2Fcallable-mixin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbongo%2Fcallable-mixin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbongo","download_url":"https://codeload.github.com/dbongo/callable-mixin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbongo%2Fcallable-mixin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263061405,"owners_count":23407606,"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":["call","callable","gem","mixin","ruby","service-object"],"created_at":"2025-07-02T02:07:40.572Z","updated_at":"2026-04-09T10:33:47.374Z","avatar_url":"https://github.com/dbongo.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Gem Version](https://badge.fury.io/rb/callable-mixin.svg)](https://badge.fury.io/rb/callable-mixin)\n[![Build Status](https://github.com/dbongo/callable-mixin/actions/workflows/ci.yml/badge.svg)](https://github.com/dbongo/callable-mixin/actions)\n\n# Callable\n\nCallable is a minimal Ruby mix-in that provides your classes with a simple `.call` class method (plus `to_proc`). It allows you to instantiate and immediately invoke an instance method (`call`) without boilerplate or additional dependencies. Perfect for clean, readable, and concise service objects.\n\nLearn more at https://rubydoc.info/gems/callable-mixin\n\n## Features\n\n- Provides a `.call` class method to any Ruby class.\n- Supports `Class#to_proc`, letting you use `\u0026YourService` in `Enumerable` methods.\n- Transparently forwards positional args, keyword args, and blocks to `#call`.\n- Raises `ConstructionError` (subclass of `ArgumentError`) for constructor arity/kwarg mismatches.\n- Raises `NotImplementedError` when the class does not define an instance `#call`.\n- Zero external runtime dependencies.\n- Compatible with MRI Ruby 2.3 through Ruby 3.x.\n\n## Installation\n\nAdd this to your application's Gemfile (version 0.2.0 or later):\n\n```ruby\ngem 'callable-mixin', '~\u003e 0.2.0'\n```\n\nThen execute:\n\n```bash\nbundle install\n```\n\nOr install directly:\n\n```bash\ngem install callable-mixin\n```\n\n## Usage\n\n### Example Service with Multiple Arguments\n\n```ruby\nclass SendNotification\n  include Callable\n\n  def initialize(user, message)\n    @user = user\n    @message = message\n  end\n\n  def call\n    NotificationMailer.notify(@user, @message).deliver_now\n  end\nend\n```\n\n- **Explicit invocation** when you need multiple constructor args:\n\n  ```ruby\n  users.each do |user|\n    SendNotification.call(user, \"Your message here\")\n  end\n\n  # You can also call via the `.()` alias:\n  SendNotification.(user, \"Your message here\")\n  ```\n\n### Example Service with Single Argument (to_proc Shorthand)\n\n```ruby\nclass WelcomeUser\n  include Callable\n\n  def initialize(user)\n    @user = user\n  end\n\n  def call\n    NotificationMailer.welcome(@user).deliver_now\n  end\nend\n```\n\n- **Proc shorthand** for one-arg services:\n\n  ```ruby\n  users.each(\u0026WelcomeUser)\n\n  # Or invoke with the `.()` alias:\n  WelcomeUser.(current_user)\n  ```\n\n### Using in a Plain Ruby Script\n\n```ruby\nrequire 'callable-mixin'\n\n# Define your service with Callable\nclass MyService\n  include Callable\n\n  def initialize(value)\n    @value = value\n  end\n\n  def call\n    puts \"Processing #{@value}\"\n  end\nend\n\n# Invoke the service\nMyService.call(\"some data\")\n\n# Or use the `.()` alias:\nMyService.(\"more data\")\n```\n\n## Development\n\nAfter cloning the repo, install dependencies with `bundle install`, then run tests with `bundle exec rspec`.\n\n## Contributing\n\nPlease follow these resources before submitting code or issues:\n\n- [Code of Conduct](https://github.com/dbongo/callable-mixin/blob/main/.github/CODE_OF_CONDUCT.md)\n- [Contributing Guide](https://github.com/dbongo/callable-mixin/blob/main/.github/CONTRIBUTING.md)\n- [Pull Request Template](https://github.com/dbongo/callable-mixin/blob/main/.github/PULL_REQUEST_TEMPLATE.md)\n\nBug reports and pull requests are welcome on GitHub: https://github.com/dbongo/callable-mixin\n\n## License\n\nThe gem is available under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbongo%2Fcallable-mixin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbongo%2Fcallable-mixin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbongo%2Fcallable-mixin/lists"}