Created
November 7, 2015 18:32
-
-
Save stoffie/3b68f98134aab8db4152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Create < Trailblazer::Operation | |
include Model | |
model Workflow | |
contract do | |
property :name | |
property :description | |
collection :steps, populate_if_empty: Step do | |
property :form, populate_if_empty: lambda { |params, *| Form.find(params[:id]) } | |
#validates :form, presence: true | |
property :user, populate_if_empty: lambda { |params, *| User.find(params[:id]) } | |
#validates :user, presence: true | |
end | |
validates :name, presence: true | |
validates :steps, presence: true, length: {minimum: 1} | |
end | |
def process(params) | |
validate(params[:workflow]) do |workflow| | |
workflow.save | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment