Sha256: 5c87e3518edeb511f227207082f55300ffed0a4d9e78fba408d5a0ebe8fcd22b

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::RealTime::TranscribeInstance
  def self.call(instance, index, properties)
    new(instance, index, properties).call
  end

  def initialize(instance, index, properties)
    @instance, @index, @properties = instance, index, properties
  end

  def call
    properties.each_with_object([document_id]) do |property, instance_values|
      begin
        instance_values << property.translate(instance)
      rescue StandardError => error
        raise_wrapper error, property
      end
    end
  end

  private

  attr_reader :instance, :index, :properties

  def document_id
    index.document_id_for_key instance.id
  end

  def raise_wrapper(error, property)
    wrapper = ThinkingSphinx::TranscriptionError.new
    wrapper.inner_exception = error
    wrapper.instance        = instance
    wrapper.property        = property

    raise wrapper
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinking-sphinx-4.0.0 lib/thinking_sphinx/real_time/transcribe_instance.rb