Module: ComplyanceSDK::Models::Mode

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

Overview

Mode enumeration

Constant Summary collapse

DOCUMENTS =

Documents mode

:documents
TEMPLATES =

Templates mode

:templates

Class Method Summary collapse

Class Method Details

.allArray<Symbol>

Get all valid modes

Returns:

  • (Array<Symbol>)

    All valid modes



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

def self.all
  [DOCUMENTS, TEMPLATES]
end

.normalize(mode) ⇒ Symbol?

Convert string to mode symbol

Parameters:

  • mode (String, Symbol)

    The mode

Returns:

  • (Symbol, nil)

    The mode symbol or nil if invalid



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

def self.normalize(mode)
  return nil if mode.nil?
  
  case mode.to_s.downcase
  when "documents"
    DOCUMENTS
  when "templates"
    TEMPLATES
  else
    mode.to_sym if valid?(mode)
  end
end

.valid?(mode) ⇒ Boolean

Check if a mode is valid

Parameters:

  • mode (Symbol, String)

    The mode to check

Returns:

  • (Boolean)

    True if valid, false otherwise



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

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