Method: Orias::Search.set_type

Defined in:
lib/orias/search.rb

.set_type(type, terms) ⇒ Object

Check & Set the type for an intermediaries list



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/orias/search.rb', line 73

def set_type(type, terms)
  type = :registrationNumber if type == :orias

  return type if VALID_INTERMEDIARIES_TYPE.key?(type)

  lgts = terms.map(&:length).uniq

  unless lgts.length == 1 && VALID_INTERMEDIARIES_TYPE.invert[lgts.first]
    raise "Orias::Search - Unknown Type Error (\"#{type}\")."
  end

  VALID_INTERMEDIARIES_TYPE.invert[lgts.first]
end