class ThinkingSphinx::ActiveRecord::AssociationProxy::AttributeFinder
Public Class Methods
new(association)
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 2 def initialize(association) @association = association end
Public Instance Methods
attribute()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 6 def attribute attributes.detect { |attribute| # Don't bother with attributes built from multiple columns next if attribute.columns.many? attribute.columns.first.__name == foreign_key.to_sym || attribute.name == foreign_key.to_s } or raise "Missing Attribute for Foreign Key #{foreign_key}" end
Private Instance Methods
attributes()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 17 def attributes sources.collect(&:attributes).flatten end
configuration()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 21 def configuration ThinkingSphinx::Configuration.instance end
foreign_key()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 25 def foreign_key @foreign_key ||= reflection_target.foreign_key end
indices()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 29 def indices @indices ||= begin configuration.preload_indices configuration.indices_for_references( *@association.klass.name.underscore.to_sym ).reject &:distributed? end end
reflection_target()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 38 def reflection_target target = @association.reflection target = target.through_reflection if target.through_reflection target end
sources()
click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb, line 44 def sources indices.collect(&:sources).flatten end