{"id":15288768,"url":"https://github.com/nsommer/model_orchestration","last_synced_at":"2026-02-02T09:15:08.593Z","repository":{"id":56884222,"uuid":"81226174","full_name":"nsommer/model_orchestration","owner":"nsommer","description":"A toolkit for orchestrating actions on related models.","archived":false,"fork":false,"pushed_at":"2017-12-21T14:06:23.000Z","size":347,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T20:04:09.889Z","etag":null,"topics":["activemodel","activerecord","rails","ruby","ruby-gem"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/model_orchestration","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nsommer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-07T15:59:01.000Z","updated_at":"2021-11-04T18:03:25.000Z","dependencies_parsed_at":"2022-08-20T23:40:41.086Z","dependency_job_id":null,"html_url":"https://github.com/nsommer/model_orchestration","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/nsommer%2Fmodel_orchestration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fmodel_orchestration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fmodel_orchestration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fmodel_orchestration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsommer","download_url":"https://codeload.github.com/nsommer/model_orchestration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427012,"owners_count":20937214,"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":["activemodel","activerecord","rails","ruby","ruby-gem"],"created_at":"2024-09-30T15:53:08.175Z","updated_at":"2026-02-02T09:15:08.538Z","avatar_url":"https://github.com/nsommer.png","language":"Ruby","readme":"# Model Orchestration - orchestrating actions on related models ![Build Status](https://travis-ci.org/nsommer/model_orchestration.svg?branch=master)\nLinks: [GitHub](https://github.com/nsommer/model_orchestration) | [Travis CI](https://travis-ci.org/nsommer/model_orchestration) | [RubyGems](https://rubygems.org/gems/model_orchestration) | [RDocs](https://nsommer.github.io/model_orchestration/)\n\nHave you ever collected multiple models (either [ActiveModel](http://api.rubyonrails.org/classes/ActiveModel/Model.html) or [ActiveRecord](http://api.rubyonrails.org/files/activerecord/README_rdoc.html)) in a controller method and had to orchestrate persisting them in the correct order? This library offers an elegant solution to this.\n\nCreate a new class, also called OrchestrationModel, which collects as many models as you like and orchestrates through validation and persistence operations. Use an easy to read DSL-like API to register nested models to this OrchestrationModel and their dependencies between each other. OrchestrationModels act like a container and behave just like an ActiveModel or ActiveRecord objects themselves. Therefore you can ceep controller methods simple without writing lots of code.\n\n## Installing the Ruby Gem\n\nIf you use [bundler](http://bundler.io) (preferred), put model_orchestration into your applications `Gemfile`.\n\n```ruby\ngem \"model_orchestration\"\n```\n\nOtherwise you can of course install it globally with `gem install model_orchestration`.\n\n## Example\n\nConsider you're developing a B2B SaaS application with a signup form. When a new client signs up, you will probably need to create multiple models and save them to the database, for example a user object, representing the person signing up and an organization object which attaches the user to a legal entity which represents your customer, billing data etc.\n\n*ModelOrchestration* allows you to nest the user model and the organization model into an OrchestrationModel, on which all the actions necessary can be performed (validation, persistence). Let's call this OrchestrationModel simply *Signup*.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  belongs_to :organization\n  validates :name, presence: true\n  validates :email, presence: true\nend\n\nclass Organization \u003c ActiveRecord::Base\n  has_many :users\n  validates :name, presence: true\nend\n\nclass Signup\n  include ModelOrchestration::Base\n  include ModelOrchestration::Persistence\n\n  nested_model :organization\n  nested_model :user\n  nested_model_dependency from: :user, to: :organization\nend\n\nsignup = Signup.new(user: {name: \"Nils\", email: \"nils@example.org\"}, organization: {name: \"Nils' Webdesign Agency\"})\n\nsignup.valid? # =\u003e true\n\nsignup.user.name # =\u003e \"Nils\"\nsignup.user # =\u003e #\u003cUser:0x007f81f498d078\u003e \nsignup[:user][:email] # =\u003e \"nils@example.org\"\n\nsignup.save # =\u003e true\n```\n\n\n## Development \u0026 Contributions\n\nTo start development on the model_orchestration itself, follow these steps.\n\n```bash\ngit clone https://github.com/nsommer/model_orchestration.git\ncd model_orchestration/\nbundle install\n```\n\nYou can run the tests with rake.\n\n```bash\nbundle exec rake\n```\n\nTo build the rdoc files, run the corresponding rake task.\n\n```bash\nbundle exec rake rdoc\n```\n\nThis generates the `docs` directory and puts all the documentation into it.\n\n## Changelog\n\nSee `CHANGELOG.md`.\n\n## License\n\nModel Orchestration is released under the [MIT license](http://www.opensource.org/licenses/MIT).    \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsommer%2Fmodel_orchestration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsommer%2Fmodel_orchestration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsommer%2Fmodel_orchestration/lists"}