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.



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

def initialize(association)
  @association = association
end

Instance Method Details

#attributeObject



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

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