Class: ThinkingSphinx::ActiveRecord::Property

Inherits:
Object
  • Object
show all
Includes:
Core::Property
Defined in:
lib/thinking_sphinx/active_record/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(model, columns, options = {}) ⇒ Property

Returns a new instance of Property.



8
9
10
11
12
13
14
15
# File 'lib/thinking_sphinx/active_record/property.rb', line 8

def initialize(model, columns, options = {})
  @model, @options = model, options

  @columns = Array(columns).collect { |column|
    column.respond_to?(:__name) ? column :
      ThinkingSphinx::ActiveRecord::Column.new(column)
  }
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



6
7
8
# File 'lib/thinking_sphinx/active_record/property.rb', line 6

def columns
  @columns
end

#modelObject (readonly)

Returns the value of attribute model.



6
7
8
# File 'lib/thinking_sphinx/active_record/property.rb', line 6

def model
  @model
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/thinking_sphinx/active_record/property.rb', line 6

def options
  @options
end

Instance Method Details

#nameObject



23
24
25
# File 'lib/thinking_sphinx/active_record/property.rb', line 23

def name
  (options[:as] || columns.first.__name).to_s
end

#rebase(associations, options) ⇒ Object



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

def rebase(associations, options)
  @columns = columns.inject([]) do |array, column|
    array + column.__replace(associations, options[:to])
  end
end

#source_typeObject



27
28
29
# File 'lib/thinking_sphinx/active_record/property.rb', line 27

def source_type
  options[:source]
end