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

- (Property) initialize(model, columns, options = {})



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

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

- (Object) columns (readonly)

Returns the value of attribute columns



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

def columns
  @columns
end

- (Object) options (readonly)

Returns the value of attribute options



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

def options
  @options
end

Instance Method Details

- (Object) name



21
22
23
# File 'lib/thinking_sphinx/active_record/property.rb', line 21

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

- (Object) rebase(associations, options)



15
16
17
18
19
# File 'lib/thinking_sphinx/active_record/property.rb', line 15

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

- (Object) source_type



25
26
27
# File 'lib/thinking_sphinx/active_record/property.rb', line 25

def source_type
  options[:source]
end