Sha256: 620b28361583b0d3351678302c902e5c137d4985a030e5e243e08710cb6f3acd
Contents?: true
Size: 827 Bytes
Versions: 5
Compression:
Stored size: 827 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 Create < Pragma::Operation::Base include Pragma::Operation::Defaults def call context.record = build_record context.contract = build_contract(context.record) validate! context.contract authorize! context.contract context.contract.save context.record.save! respond_with status: :created, resource: decorate(context.record) end protected # Builds the requested record. # # @return [Object] def build_record self.class.model_klass.new end end end end
Version data entries
5 entries across 5 versions & 1 rubygems