{"id":15510584,"url":"https://github.com/kortirso/service_operator","last_synced_at":"2025-10-08T10:48:51.437Z","repository":{"id":59176866,"uuid":"529857222","full_name":"kortirso/service_operator","owner":"kortirso","description":"Simple interactor is a gem based on ideas of gems interactor and dry-transaction. ServiceOperator provides a simple way to processing over many steps and by many different objects.","archived":false,"fork":false,"pushed_at":"2022-09-18T12:48:32.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-02T02:20:09.689Z","etag":null,"topics":["interactor","organizer","rails","ruby","service-objects"],"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/kortirso.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":"2022-08-28T12:34:19.000Z","updated_at":"2022-10-11T19:06:16.000Z","dependencies_parsed_at":"2022-09-13T00:22:40.612Z","dependency_job_id":null,"html_url":"https://github.com/kortirso/service_operator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/kortirso/service_operator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kortirso%2Fservice_operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kortirso%2Fservice_operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kortirso%2Fservice_operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kortirso%2Fservice_operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kortirso","download_url":"https://codeload.github.com/kortirso/service_operator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kortirso%2Fservice_operator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278931654,"owners_count":26070788,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["interactor","organizer","rails","ruby","service-objects"],"created_at":"2024-10-02T09:49:40.930Z","updated_at":"2025-10-08T10:48:51.404Z","avatar_url":"https://github.com/kortirso.png","language":"Ruby","readme":"# ServiceOperator\nSimple interactor is a gem based on ideas of gems [interactor](https://github.com/collectiveidea/interactor) and [dry-transaction](https://github.com/dry-rb/dry-transaction). ServiceOperator provides a simple way to processing over many steps and by many different objects.\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'service_operator'\n```\n\nAnd then execute:\n```bash\n$ bundle install\n```\n\n## Usage\n\n### Initializer\n\nAdd configuration to config/initializers/service_operator.rb:\n```ruby\nServiceOperator.configure do |config|\n  config.call_parameters_method_name = :call_parameters\nend\n```\n\n### ApplicationOperator\n\nYou can create ApplicationOperator - basis class for your operators\n```ruby\nclass ApplicationOperator\n  include ServiceOperator::Helpers\n\n  private\n\n  # this around action is useful when you need to wrap your steps inside transaction\n  def use_transaction(operator)\n    ActiveRecord::Base.transaction do\n      operator.call\n    end\n  end\nend\n```\n\nAnd then you can start creating operators for wrapping services with business logic\n```ruby\nmodule Weeks\n  class RefreshOperator \u003c ApplicationOperator\n    # validating provided parameters for operator\n    required_context :week\n\n    # definition for around hooks\n    around :use_transaction\n\n    # definition for before hooks\n    before :turn_off\n\n    # definition for main steps\n    step :finish_week, service: Weeks::FinishService, week: :previous_week\n    step :start_week, service: Weeks::StartService\n    step :prepare_week, service: Weeks::ComingService\n\n    # definition for after hooks\n    after :turn_on\n\n    private\n\n    def turn_off; end\n\n    def turn_on; end\n\n    def previous_week\n      context.week.previous\n    end\n  end\nend\n```\n\nAnd run your operator\n```ruby\n  Weeks::RefreshOperator.call(week: week)\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 the created tag, 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/kortirso/service_operator.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkortirso%2Fservice_operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkortirso%2Fservice_operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkortirso%2Fservice_operator/lists"}