Module: Minfraud::Resolver

Included in:
Assessments
Defined in:
lib/minfraud/resolver.rb

Overview

Resolver provides functionality for setting component attributes.

Class Method Summary collapse

Class Method Details

.assign(context, params) ⇒ Array

Set keys on the context based on the provided parameters.

Parameters:

  • context (Object)

    An object for variable assignment.

  • params (Hash)

    A hash of parameters.

Returns:

  • (Array)

Raises:



16
17
18
19
20
21
22
23
# File 'lib/minfraud/resolver.rb', line 16

def assign(context, params)
  Array(params).each do |key, value|
    raise RequestFormatError, "#{key} does not belong to request document format" unless MAPPING[key]

    entity = MAPPING[key].new(value) unless value.is_a?(MAPPING[key])
    context.send("#{key}=", entity || value)
  end
end