Module: Ultrasphinx::Associations
- Included in:
- Configure, Fields, Search::Internals
- Defined in:
- lib/ultrasphinx/associations.rb
Instance Method Summary collapse
- #entry_identifies_association?(entry) ⇒ Boolean
- #get_association(klass, entry) ⇒ Object
- #get_association_model(klass, entry) ⇒ Object
Instance Method Details
#entry_identifies_association?(entry) ⇒ Boolean
20 21 22 |
# File 'lib/ultrasphinx/associations.rb', line 20 def entry_identifies_association?(entry) entry['class_name'] || entry['association_name'] end |
#get_association(klass, entry) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/ultrasphinx/associations.rb', line 4 def get_association(klass, entry) if value = entry['class_name'] klass.reflect_on_all_associations.detect do |assoc| assoc.class_name == value end elsif value = entry['association_name'] klass.reflect_on_all_associations.detect do |assoc| assoc.name.to_s == value.to_s end end end |
#get_association_model(klass, entry) ⇒ Object
16 17 18 |
# File 'lib/ultrasphinx/associations.rb', line 16 def get_association_model(klass, entry) get_association(klass, entry).class_name.constantize end |