Class: ThinkingSphinx::ActiveRecord::PropertyQuery

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/active_record/property_query.rb

Direct Known Subclasses

SimpleManyQuery

Instance Method Summary collapse

Constructor Details

#initialize(property, source, type = nil) ⇒ PropertyQuery



2
3
4
# File 'lib/thinking_sphinx/active_record/property_query.rb', line 2

def initialize(property, source, type = nil)
  @property, @source, @type = property, source, type
end

Instance Method Details

#to_sObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thinking_sphinx/active_record/property_query.rb', line 6

def to_s
  if unsafe_habtm_column?
    raise <<-MESSAGE
Source queries cannot be used with HABTM joins if they use anything beyond the
primary key.
    MESSAGE
  end

  if safe_habtm_column?
    ThinkingSphinx::ActiveRecord::SimpleManyQuery.new(
      property, source, type
    ).to_s
  else
    "#{identifier} from #{source_type}; #{queries.join('; ')}"
  end
end