Class: ThinkingSphinx::RealTime::Property

Inherits:
Object
  • Object
show all
Includes:
Core::Property
Defined in:
lib/thinking_sphinx/real_time/property.rb

Direct Known Subclasses

Attribute, Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Core::Property

#facet?, #multi?, #type

Constructor Details

#initialize(column, options = {}) ⇒ Property

Returns a new instance of Property



6
7
8
9
10
# File 'lib/thinking_sphinx/real_time/property.rb', line 6

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

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column



4
5
6
# File 'lib/thinking_sphinx/real_time/property.rb', line 4

def column
  @column
end

#optionsObject (readonly)

Returns the value of attribute options



4
5
6
# File 'lib/thinking_sphinx/real_time/property.rb', line 4

def options
  @options
end

Instance Method Details

#nameObject



12
13
14
# File 'lib/thinking_sphinx/real_time/property.rb', line 12

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

#translate(object) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/thinking_sphinx/real_time/property.rb', line 16

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