Sha256: c566343d9f97fc7732ce63fbdbe35c0f807078ec3c2c1800cc4b01a87c67f0e1

Contents?: true

Size: 583 Bytes

Versions: 5

Compression:

Stored size: 583 Bytes

Contents

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", ''
  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

5 entries across 5 versions & 1 rubygems

Version Path
thinking-sphinx-3.4.2 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-3.4.1 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-3.4.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-3.3.0 lib/thinking_sphinx/real_time/translator.rb
thinking-sphinx-3.2.0 lib/thinking_sphinx/real_time/translator.rb