Class: RestPack::Service::Commands::Update
- Inherits:
-
RestPack::Service::Command
- Object
- Mutations::Command
- RestPack::Service::Command
- RestPack::Service::Commands::Update
- Defined in:
- lib/restpack_service/commands/update.rb
Instance Attribute Summary
Attributes inherited from RestPack::Service::Command
Instance Method Summary collapse
Methods inherited from RestPack::Service::Command
#Model, #Serializer, #field_error, inherited, #init, #run, #service_error, #status, #valid?
Instance Method Details
#execute ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/restpack_service/commands/update.rb', line 5 def execute key = self.class.serializer_class.key result = { key => [] } self.class.model_class.transaction do inputs[key].each do |model_inputs| model = find_model(model_inputs) if model model = update_model(model, model_inputs) result[key] << self.class.serializer_class.as_json(model) else status :not_found end end end result end |