Sha256: bbfb5130a512b0712c57651a00358cab9e84757f735e3194010299641e251321

Contents?: true

Size: 638 Bytes

Versions: 10

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

class ThinkingSphinx::RealTime::Translator
  def self.call(object, column)
    new(object, column).call
  end

  def initialize(object, column)
    @object, @column = object, column
  end

  def call
    return name   unless name.is_a?(Symbol)
    return result unless result.is_a?(String)

    result.gsub("\u0000", '').force_encoding "UTF-8"
  end

  private

  attr_reader :object, :column

  def name
    @column.__name
  end

  def owner
    stack.inject(object) { |previous, node| previous.try node }
  end

  def result
    @result ||= owner.try name
  end

  def stack
    @column.__stack
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
thinking-sphinx-5.1.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/real_time/translator.rb