Sha256: 1c27dd11ccdf480a3ebe80ad21808684c52b840071c5305bfd94fb4df90708b1

Contents?: true

Size: 688 Bytes

Versions: 17

Compression:

Stored size: 688 Bytes

Contents

# frozen_string_literal: true

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

  attr_reader :model, :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

17 entries across 17 versions & 1 rubygems

Version Path
thinking-sphinx-5.6.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.5.1 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.5.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.4.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.3.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.2.1 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.2.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.1.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-5.0.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.4.1 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.4.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.3.2 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.3.1 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.3.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.2.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.1.0 lib/thinking_sphinx/active_record/property.rb
thinking-sphinx-4.0.0 lib/thinking_sphinx/active_record/property.rb