OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/lib/services/create_relation.rb

18 lines
421 B

class Services::CreateRelation
def initialize(from_work_package, to_work_package, attrs = {})
@relation = from_work_package.new_relation.tap do |r|
r.to = to_work_package
r.relation_type = attrs[:relation_type]
r.delay = attrs[:delay]
end
end
def run(success = -> {}, failure = -> {})
if @relation.save
success.(created: true)
else
error.(@relation)
end
end
end