Sha256: 9ad62ccdbe494f3dd1cec83dcef1fd1e01ae0677344aa68727645db89e502723

Contents?: true

Size: 618 Bytes

Versions: 4

Compression:

Stored size: 618 Bytes

Contents

class ThinkingSphinx::RealTime::Property
  include ThinkingSphinx::Core::Property

  attr_reader :column, :options

  def initialize(column, options = {})
    @options = options
    @column  = column.respond_to?(:__name) ? column :
      ThinkingSphinx::ActiveRecord::Column.new(column)
  end

  def name
    (@options[:as] || @column.__name).to_s
  end

  def translate(object)
    return @column.__name unless @column.__name.is_a?(Symbol)

    base = @column.__stack.inject(object) { |base, node| base.try(node) }
    base = base.try(@column.__name)
    base.is_a?(String) ? base.gsub("\u0000", '') : base
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thinking-sphinx-3.1.4 lib/thinking_sphinx/real_time/property.rb
thinking-sphinx-3.1.3 lib/thinking_sphinx/real_time/property.rb
thinking-sphinx-3.1.2 lib/thinking_sphinx/real_time/property.rb
thinking-sphinx-3.1.1 lib/thinking_sphinx/real_time/property.rb