Sha256: a74543d5a71b668be1ea64a164ff6d27197c8f6e62c17c325d93675b811943f9

Contents?: true

Size: 649 Bytes

Versions: 6

Compression:

Stored size: 649 Bytes

Contents

class ThinkingSphinx::ActiveRecord::Property
  include ThinkingSphinx::Core::Property

  attr_reader :columns, :options

  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

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

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

  def source_type
    options[:source]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
thinking-sphinx-3.0.6 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-3.0.5 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-3.0.4 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-3.0.3 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-3.0.2 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-3.0.1 lib/thinking_sphinx/active_record/property.rb