Sha256: f1683d9d05bf0b8ffd188acf92134a17f49b09c322dc6f00edf90da065d8f2a5

Contents?: true

Size: 662 Bytes

Versions: 5

Compression:

Stored size: 662 Bytes

Contents

module Ultrasphinx
  module Associations
  
    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
    
    def get_association_model(klass, entry)
      association = get_association(klass, entry)
      if association
        association.class_name.constantize
      else
        entry['class_name'].constantize
      end
    end  
          
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
pager-ultrasphinx-1.0.20080510 lib/ultrasphinx/associations.rb
pager-ultrasphinx-1.0.20080514 lib/ultrasphinx/associations.rb
ultrasphinx-1.11 lib/ultrasphinx/associations.rb
ultrasphinx-1.9 lib/ultrasphinx/associations.rb
ultrasphinx-1.8 lib/ultrasphinx/associations.rb