Class: Pragma::Operation::Update

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

Overview

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

Author:

  • Alessandro Desantis

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/update.rb', line 11

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