Class: ThinkingSphinx::ActiveRecord::AssociationProxy::AttributeFinder

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

Instance Method Summary collapse

Constructor Details

#initialize(association) ⇒ AttributeFinder

Returns a new instance of AttributeFinder



2
3
4
# File 'lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb', line 2

def initialize(association)
  @association = association
end

Instance Method Details

#attributeObject



6
7
8
9
10
11
12
# File 'lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb', line 6

def attribute
  attributes.detect { |attribute|
    ThinkingSphinx::ActiveRecord::AssociationProxy::AttributeMatcher.new(
      attribute, foreign_key
    ).matches?
  } or raise "Missing Attribute for Foreign Key #{foreign_key}"
end