Sha256: b9678dbf84f0bb842c1531a2b6ffaf644e507e70efca83b1a7f30d7c99b621c5
Contents?: true
Size: 958 Bytes
Versions: 4
Compression:
Stored size: 958 Bytes
Contents
# frozen_string_literal: true require_relative '../operation' require_relative 'resource' module LedgerSync module Domains class Operation class Update < Resource private def operate return failure('Resource not found') unless resource if resource.update(params.except(:id)) success else failure( 'Please review the problems below:', data: serialize(resource: resource) ) end end def resource @resource ||= resource_class.find_by(id: params[:id]) end def success super(resource) end def failure(message, data: nil) super( LedgerSync::Error::OperationError.new( operation: self, message: message, response: data ) ) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems