Class: Pragma::Operation::Create

Inherits:
Base
  • Object
show all
Includes:
Defaults
Defined in:
lib/pragma/operation/create.rb

Overview

Finds the requested record, authorizes it, updates it accordingly to the parameters and responds with the decorated record.

Instance Method Summary collapse

Methods included from Defaults

included

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pragma/operation/create.rb', line 11

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