Skip to content

Instantly share code, notes, and snippets.

@madzhuga
Created February 4, 2015 19:12
Show Gist options
  • Save madzhuga/9250155106b242bdadd1 to your computer and use it in GitHub Desktop.
Save madzhuga/9250155106b242bdadd1 to your computer and use it in GitHub Desktop.
Rails Workflow Engine operation template example
module DemoTemplates
class StockProvisioning < Workflow::OperationTemplate
def resolve_dependency operation
resource = operation.data[:resource]
# resource is order.
# for every order line we check if product needs provisioning
# (if it's amount lower that provisioning limit)
resource.order_lines.map(:product).any?{|p| p.need_provisioning? }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment