Class: ThinkingSphinx::ActiveRecord::PropertySQLPresenter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, adapter, associations) ⇒ PropertySQLPresenter

Returns a new instance of PropertySQLPresenter.



6
7
8
# File 'lib/thinking_sphinx/active_record/property_sql_presenter.rb', line 6

def initialize(property, adapter, associations)
  @property, @adapter, @associations = property, adapter, associations
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



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

def adapter
  @adapter
end

#associationsObject (readonly)

Returns the value of attribute associations.



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

def associations
  @associations
end

#propertyObject (readonly)

Returns the value of attribute property.



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

def property
  @property
end

Instance Method Details

#to_groupObject



10
11
12
13
14
# 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_selectObject



16
17
18
19
20
# 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