Sha256: b34c68ea85068cb1b3d84dcdfc4e4f67ee70998ba02a5a286d6a43b0f5088ecf

Contents?: true

Size: 964 Bytes

Versions: 4

Compression:

Stored size: 964 Bytes

Contents

# frozen_string_literal: true

module Yoti
  module DocScan
    module Session
      module Create
        #
        # Requests creation of a Task to be performed on each document
        #
        class RequestedTask
          #
          # @param [String] type The type of the Task to create
          # @param [#as_json] config Configuration to apply to the Task
          #
          def initialize(type, config)
            raise(TypeError, "#{self.class} cannot be instantiated") if self.class == RequestedTask

            Validation.assert_is_a(String, type, 'type')
            @type = type

            Validation.assert_respond_to(:as_json, config, 'config')
            @config = config
          end

          def to_json(*_args)
            as_json.to_json
          end

          def as_json(*_args)
            {
              type: @type,
              config: @config.as_json
            }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoti-1.9.0 lib/yoti/doc_scan/session/create/requested_task.rb
yoti-1.8.0 lib/yoti/doc_scan/session/create/requested_task.rb
yoti-1.7.1 lib/yoti/doc_scan/session/create/requested_task.rb
yoti-1.7.0 lib/yoti/doc_scan/session/create/requested_task.rb