{"id":15672590,"url":"https://github.com/dreikanter/callee","last_synced_at":"2025-08-12T18:43:49.181Z","repository":{"id":35038694,"uuid":"199196469","full_name":"dreikanter/callee","owner":"dreikanter","description":"A Ruby gem to make classes callable","archived":false,"fork":false,"pushed_at":"2024-10-28T18:48:30.000Z","size":59,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-06T21:06:02.257Z","etag":null,"topics":["callables","hacktoberfest","helpers","ruby","ruby-gems"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/callee","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/dreikanter.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,"zenodo":null}},"created_at":"2019-07-27T17:45:46.000Z","updated_at":"2024-08-29T20:35:53.000Z","dependencies_parsed_at":"2025-05-06T21:06:04.297Z","dependency_job_id":"b5a737ef-9ca1-4c7b-9bc9-21e6cb697683","html_url":"https://github.com/dreikanter/callee","commit_stats":{"total_commits":44,"total_committers":2,"mean_commits":22.0,"dds":"0.022727272727272707","last_synced_commit":"2f88ec390ec0f20e91b834efb6a9ce8497d4e8f0"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dreikanter/callee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreikanter%2Fcallee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreikanter%2Fcallee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreikanter%2Fcallee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreikanter%2Fcallee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreikanter","download_url":"https://codeload.github.com/dreikanter/callee/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreikanter%2Fcallee/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262647590,"owners_count":23342676,"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":["callables","hacktoberfest","helpers","ruby","ruby-gems"],"created_at":"2024-10-03T15:28:44.090Z","updated_at":"2025-06-29T18:32:59.397Z","avatar_url":"https://github.com/dreikanter.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Callee\n\nThis gem helps to define callable classes with strict params specification.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'callee'\n```\n\nAnd then execute:\n\n```sh\nbundle\n```\n\nOr install it yourself as:\n\n```sh\ngem install callee\n```\n\n## Usage\n\nTo make a class callable, you need to include `Callee` mixin and implement `call` instance method. Use [dry-initializer DSL](https://dry-rb.org/gems/dry-initializer/3.0/) to specify calling parameters and options if necessary. Here is a basic usage example:\n\n``` ruby\nclass Power\n  include Callee\n\n  # Required parameter\n  param :base\n  \n  # Option with a default value\n  option :exponent, optional: true, default: -\u003e { 2 }\n\n  def call\n    base.pow(exponent)\n  end\nend\n\nPower.call(2)  # =\u003e 4\nPower.call(2, exponent: 10)  # =\u003e 1024\n```\n\nCallable class may be used as a Proc. Compact notation in the next example is identical to `[1, 2, 3].map { |value| Power.call(value) }`\n\n``` ruby\n[1, 2, 3].map(\u0026Power)  # =\u003e [1, 4, 9]\n```\n\nSince Callee mixin inherits `dry-initializer` DSL, type constraints and coercion will also work, as usual. Just make sure to include `dry-types`:\n\n``` ruby\nrequire \"dry-types\"\n\nclass StrictPower\n  include Callee\n\n  param :base, type: Dry::Types[\"strict.integer\"]\n  option :exponent, type: Dry::Types[\"strict.integer\"], optional: true, default: -\u003e { 2 }\n\n  def call\n    base.pow(exponent)\n  end\nend\n\n# Let's inherit StrictPower params definition\n# and override \"base\" with more forgiving constraint\nclass CoerciblePower \u003c StrictPower\n  param :value, type: Dry::Types[\"coercible.integer\"]\nend\n\nstring_values = %w[1 2 3]\n\nstring_values.map(\u0026StrictPower)  # Will raise Dry::Types::ConstraintError\nstring_values.map(\u0026CoerciblePower)  # =\u003e [1, 4, 9]\n```\n\nSee [more examples](https://dry-rb.org/gems/dry-initializer/type-constraints/) in dry-rb docs.\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/dreikanter/callee.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreikanter%2Fcallee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreikanter%2Fcallee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreikanter%2Fcallee/lists"}