Sha256: f3686a82c18e27f4b5f1ad644cf36b287c1bf019c860b33bf7a857bb81054b50
Contents?: true
Size: 833 Bytes
Versions: 2
Compression:
Stored size: 833 Bytes
Contents
# frozen_string_literal: true module Pragma module Operation # Finds the requested record, authorizes it, updates it accordingly to the parameters and # responds with the decorated record. # # @author Alessandro Desantis class Update < Pragma::Operation::Base include Pragma::Operation::Defaults def call context.record = find_record context.contract = build_contract(context.record) validate! context.contract authorize! context.contract context.contract.save context.record.save! respond_with resource: decorate(context.record), status: :ok end protected # Finds the requested record. # # @return [Object] def find_record self.class.model_klass.find(params[:id]) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pragma-1.2.6 | lib/pragma/operation/update.rb |
pragma-1.2.5 | lib/pragma/operation/update.rb |