class ThinkingSphinx::ActiveRecord::AssociationProxy::AttributeMatcher

Attributes

attribute[R]
foreign_key[R]

Public Class Methods

new(attribute, foreign_key) click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 4
def initialize(attribute, foreign_key)
  @attribute, @foreign_key = attribute, foreign_key.to_s
end

Public Instance Methods

matches?() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 8
def matches?
  return false if many?

  column_name_matches? || attribute_name_matches? || multi_singular_match?
end

Private Instance Methods

attribute_name_matches?() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 20
def attribute_name_matches?
  name == foreign_key
end
column() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 28
def column
  attribute.respond_to?(:columns) ? attribute.columns.first :
    attribute.column
end
column_name_matches?() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 24
def column_name_matches?
  column.__name.to_s == foreign_key
end
many?() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 33
def many?
  attribute.respond_to?(:columns) && attribute.columns.many?
end
multi_singular_match?() click to toggle source
# File lib/thinking_sphinx/active_record/association_proxy/attribute_matcher.rb, line 37
def multi_singular_match?
  multi? && name.singularize == foreign_key
end