Module: InternalAffairs::OperationManager

Included in:
InternalAffairs
Defined in:
lib/internal_affairs/operation_manager.rb

Instance Method Summary collapse

Instance Method Details

#request_operation_approval(_target) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/internal_affairs/operation_manager.rb', line 3

def request_operation_approval(_target)
  uuid = SecureRandom.uuid

  response = InternalAffairs::ApiUtils.create_operation(
    uuid: uuid,
    user: _target.approvable_user,
    name: _target.approvable_operation,
    amount: _target.approvable_amount,
    resources: _target.approvable_resources
  )

  if response.state == 'approved'
    _target.approve!
  else
    InternalAffairs::PendingOperation.create! operation_uuid: uuid, target: _target
  end
end