{"id":19404933,"url":"https://github.com/samesystem/same-interactor","last_synced_at":"2025-04-28T11:10:46.798Z","repository":{"id":80684203,"uuid":"238194461","full_name":"samesystem/same-interactor","owner":"samesystem","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-31T04:52:56.000Z","size":43,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-01-31T05:26:00.759Z","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":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samesystem.png","metadata":{"files":{"readme":"docs/README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-02-04T11:54:21.000Z","updated_at":"2025-01-31T04:53:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"518d60fc-5641-4804-8129-4d4801583b1e","html_url":"https://github.com/samesystem/same-interactor","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samesystem%2Fsame-interactor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samesystem%2Fsame-interactor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samesystem%2Fsame-interactor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samesystem%2Fsame-interactor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samesystem","download_url":"https://codeload.github.com/samesystem/same-interactor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240582047,"owners_count":19824145,"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-10T11:36:43.279Z","updated_at":"2025-02-25T00:44:32.909Z","avatar_url":"https://github.com/samesystem.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Same::Interactor\n\n[![Build Status](https://travis-ci.org/samesystem/same-interactor.svg?branch=master)](https://travis-ci.org/samesystem/same-interactor)\n[![codecov](https://codecov.io/gh/samesystem/same-interactor/branch/master/graph/badge.svg)](https://codecov.io/gh/samesystem/same-interactor)\n[![Documentation](https://readthedocs.org/projects/ansicolortags/badge/?version=latest)](https://samesystem.github.io/same-interactor)\n\nService / Interactor on steroids.\n\n## Full Documentation\n\nCheck https://samesystem.github.io/same-interactor for more details\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'same-interactor'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install same-interactor\n\n\n## Getting started\n\nThis Same::Interactor is build on top of [Interactor](https://github.com/collectiveidea/interactor) gem. So everything what works with `Interactor` should work with `Same::Interactor` too. `Same::Interactor` just adds few additional features:\n* `context_attr` which allows to define required context attributes or attributes with defaults\n* validations which fails interactor before executing `call` method when validations fails. Also it returns validation errors.\n\n## Usage\n\n```ruby\nclass MyService\n  include Same::Interactor\n\n  validates :my_positive_number, numericality: { greater_than: 0 }\n\n  context_attr :my_attr\n  context_attr :my_optional_attr, optional: true\n  context_attr :my_attr_with_default, default: -\u003e { my_attr }\n  context_attr :my_positive_number\n\n  def call\n    context.received_my_attr_with_default = my_attr_with_default\n  end\nend\n\n# validations:\nresult = MyService.call(my_attr: 'foo', my_positive_number: -1000)\nresult.success? # =\u003e false\nresult.errors.full_messages # =\u003e [\"My positive number must be greater than 0\"]\n\n# using defaults:\nresult = MyService.call(my_attr: 'foo', my_positive_number: 1)\nresult.received_my_attr_with_default # =\u003e \"foo\"\nresult = MyService.call(my_attr: 'foo', my_positive_number: 1, my_attr_with_default: 'bar')\nresult.received_my_attr_with_default # =\u003e \"bar\"\n\n# missing required context_attr\nMyService.call(my_positive_number: 1) # =\u003e raises Same::Interactor::MissingAttributeError\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` 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/samesystem/same-interactor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Same::Interactor project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/samesystem/same-interactor/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamesystem%2Fsame-interactor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamesystem%2Fsame-interactor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamesystem%2Fsame-interactor/lists"}