class ThinkingSphinx::ActiveRecord::PropertySQLPresenter
Attributes
adapter[R]
associations[R]
property[R]
Public Class Methods
new(property, adapter, associations)
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 6 def initialize(property, adapter, associations) @property, @adapter, @associations = property, adapter, associations end
Public Instance Methods
to_group()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 10 def to_group return nil if sourced_by_query? || !group? columns_with_table end
to_select()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 16 def to_select return nil if sourced_by_query? "#{casted_column_with_table} AS #{adapter.quote property.name}" end
Private Instance Methods
aggregate?()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 26 def aggregate? column_presenters.any? &:aggregate? end
aggregate_separator()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 30 def aggregate_separator multi? ? ',' : ' ' end
cast_to_timestamp(clause)
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 34 def cast_to_timestamp(clause) return adapter.cast_to_timestamp clause if property.columns.any?(&:string?) clause.split(', ').collect { |part| adapter.cast_to_timestamp part }.join(', ') end
casted_column_with_table()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 42 def casted_column_with_table clause = columns_with_table clause = cast_to_timestamp clause if property.type == :timestamp clause = concatenate clause if aggregate? clause = adapter.group_concatenate(clause, aggregate_separator) end clause end
column_presenters()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 53 def column_presenters @column_presenters ||= property.columns.collect { |column| ThinkingSphinx::ActiveRecord::ColumnSQLPresenter.new( property.model, column, adapter, associations ) } end
columns_with_table()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 61 def columns_with_table column_presenters.collect(&:with_table).compact.join(', ') end
concatenate(clause)
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 69 def concatenate(clause) return clause unless concatenating? if property.type.nil? adapter.concatenate clause, ' ' else clause = clause.split(', ').collect { |part| adapter.cast_to_string part }.join(', ') adapter.concatenate clause, ',' end end
concatenating?()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 65 def concatenating? property.columns.length > 1 end
group?()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 82 def group? !(aggregate? || property.columns.any?(&:string?)) end
sourced_by_query?()
click to toggle source
# File lib/thinking_sphinx/active_record/property_sql_presenter.rb, line 86 def sourced_by_query? property.source_type.to_s[/query/] end