Module: ComplyanceSDK::Models::Operation

Defined in:
lib/complyance_sdk/models/operation.rb

Overview

Operation enumeration

Constant Summary collapse

SINGLE =

Single document operation

:single
BATCH =

Batch document operation

:batch

Class Method Summary collapse

Class Method Details

.allArray<Symbol>

Get all valid operations

Returns:

  • (Array<Symbol>)

    All valid operations



16
17
18
# File 'lib/complyance_sdk/models/operation.rb', line 16

def self.all
  [SINGLE, BATCH]
end

.normalize(operation) ⇒ Symbol?

Convert string to operation symbol

Parameters:

  • operation (String, Symbol)

    The operation

Returns:

  • (Symbol, nil)

    The operation symbol or nil if invalid



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/complyance_sdk/models/operation.rb', line 33

def self.normalize(operation)
  return nil if operation.nil?
  
  case operation.to_s.downcase
  when "single"
    SINGLE
  when "batch"
    BATCH
  else
    operation.to_sym if valid?(operation)
  end
end

.valid?(operation) ⇒ Boolean

Check if an operation is valid

Parameters:

  • operation (Symbol, String)

    The operation to check

Returns:

  • (Boolean)

    True if valid, false otherwise



24
25
26
27
# File 'lib/complyance_sdk/models/operation.rb', line 24

def self.valid?(operation)
  return false if operation.nil?
  all.include?(operation.to_sym)
end