16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/moogle/commands/update_target.rb', line 16
def call
target_model = opts :target_model, Moogle::Target
event_class = opts :event_class, Moogle::Events::TargetUpdated
representer = opts :representer, Moogle::TargetRepresenter
target = target_model.get request.target_id
raise '404 Not found' unless target
result = target.update update_params
raise target.errors.full_messages.join('; ') unless target.saved?
target_rep = target.dup.extend representer
return event_class.new request.create_child_uuids.merge(target: target)
rescue => e
e.extend Moogle::Error
raise e
end
|