Sha256: 14dfe5c2260cc7fe3911fe08b03b746df5432877b82d57c346f97021adf56e51

Contents?: true

Size: 687 Bytes

Versions: 3

Compression:

Stored size: 687 Bytes

Contents

# encoding: utf-8
module Dynamoid #:nodoc:

  # The has_many association.
  module Associations
    class HasMany
      include ManyAssociation

      private

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dynamoid-2.2.0 lib/dynamoid/associations/has_many.rb
dynamoid-2.1.0 lib/dynamoid/associations/has_many.rb
dynamoid-2.0.0 lib/dynamoid/associations/has_many.rb