Sha256: aa1d58498b66eb599d7f478d2f1bdee5af9900acfc104fd022f6af0a269994bd

Contents?: true

Size: 667 Bytes

Versions: 4

Compression:

Stored size: 667 Bytes

Contents

module Dynomite
  module Associations
    class HasAndBelongsToMany
      include ManyAssociation

      private

      # Find the target association, always another :has_and_belongs_to_many association. Uses either options[:inverse_of] or the source class name
      # and default parsing to return the most likely name for the target association.
      def target_association
        key_name = options[:inverse_of] || source.class.to_s.pluralize.underscore.to_sym
        guess = target_class.associations[key_name]
        return nil if guess.nil? || guess[:type] != :has_and_belongs_to_many

        association_method_name(key_name)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynomite-2.0.3 lib/dynomite/associations/has_and_belongs_to_many.rb
dynomite-2.0.2 lib/dynomite/associations/has_and_belongs_to_many.rb
dynomite-2.0.1 lib/dynomite/associations/has_and_belongs_to_many.rb
dynomite-2.0.0 lib/dynomite/associations/has_and_belongs_to_many.rb