Sha256: 3243e36d32234f233b6d6f642e67dc1f8e31346cb84b4c5f69f4b4649350ffbc
Contents?: true
Size: 955 Bytes
Versions: 16
Compression:
Stored size: 955 Bytes
Contents
require 'jsonapi/operation_result' module JSONAPI class OperationsProcessor def process(request) @results = [] @resources = [] context = request.context transaction { request.operations.each do |operation| before_operation(context, operation) result = operation.apply(context) after_operation(context, result) @results.push(result) if result.has_errors? rollback end end } @results end def before_operation(context, operation) end def after_operation(context, result) end private # The base OperationsProcessor provides no transaction support # Override the transaction and rollback methods to provide transaction support. # For ActiveRecord transactions you can use the ActiveRecordOperationsProcessor def transaction yield end def rollback end end end
Version data entries
16 entries across 16 versions & 1 rubygems