class ThinkingSphinx::ActiveRecord::Depolymorph::ConditionsReflection

The conditions approach is only available in Rails 3. This behaviour is superseded by ScopedReflection for Rails 4.0.

Public Instance Methods

call() click to toggle source
# File lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb, line 8
def call
  klass.new reflection.macro, name, options, active_record
end

Private Instance Methods

condition() click to toggle source
# File lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb, line 16
def condition
  "::ts_join_alias::.#{quoted_foreign_type} = '#{class_name}'"
end
options() click to toggle source
# File lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb, line 20
def options
  super

  case @options[:conditions]
  when nil
    @options[:conditions] = condition
  when Array
    @options[:conditions] << condition
  when Hash
    @options[:conditions].merge! foreign_type => @options[:class_name]
  else
    @options[:conditions] = "#{@options[:conditions]} AND #{condition}"
  end

  @options
end
quoted_foreign_type() click to toggle source
# File lib/thinking_sphinx/active_record/depolymorph/conditions_reflection.rb, line 37
def quoted_foreign_type
  active_record.connection.quote_column_name foreign_type
end