Sha256: bb5f6e6c53463c9cb03047153b0257e9a0499a04ea83f5dd1128213c64a8c1f3
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require_relative '../operation' require_relative 'resource' module LedgerSync module Domains class Operation class Update < Resource class Contract < LedgerSync::Ledgers::Contract params do required(:id).filled(:integer) required(:limit).value(:hash) required(:data).value(:hash) end end private def operate return failure('Resource not found') unless resource if resource.update(params[:data]) success else failure( 'Please review the problems below:', data: serialize(resource: resource) ) end end def resource @resource ||= resource_class.where(params[:limit]).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
6 entries across 6 versions & 1 rubygems