WIP: use model step for creating a new record

This commit is contained in:
Loïc Guitaut 2024-11-07 10:32:06 +01:00
parent 6158a1ae29
commit bfca9aba64
No known key found for this signature in database
1 changed files with 3 additions and 8 deletions

View File

@ -19,9 +19,8 @@ class Flags::CreateFlag
validates :applies_to, inclusion: { in: -> { Flag.valid_applies_to_types } }, allow_nil: false
end
policy :unique_name
model :flag, :instantiate_flag
transaction do
step :create
model :flag, :create_flag
step :log
end
@ -35,12 +34,8 @@ class Flags::CreateFlag
!Flag.custom.where(name: params.name).exists?
end
def instantiate_flag(params:)
Flag.new(params.merge(notify_type: true))
end
def create(flag:)
flag.save!
def create_flag(params:)
Flag.create(params.merge(notify_type: true))
end
def log(guardian:, flag:)