Skip to content

Instantly share code, notes, and snippets.

@alexpeachey
Last active October 11, 2017 19:21
Show Gist options
  • Save alexpeachey/29511d7cc338b54e98596cb51a80de96 to your computer and use it in GitHub Desktop.
Save alexpeachey/29511d7cc338b54e98596cb51a80de96 to your computer and use it in GitHub Desktop.
Example Transaction 2
module Transactions
module Posts
Create = Dry.Transaction(container: {}) do
step :validate, with: Components::Common::Validate.call(schema: Schemas::Post::Create)
step :load_topic, with: Components::Common::LoadModel.call(id: :topic_id, class: Topic, model: :topic)
step :build_post, with: Components::Posts::Create::BuildPost
step :save_post, with: Components::Common::Save.call(model: :post)
step :extract_post, with: Components::Common::Extract::Extract(key: :post)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment