Sha256: a85f9e6e8768be3991d8b60958586d2e9bd6dd15ca21edf3e81cf377fcad144b

Contents?: true

Size: 1.4 KB

Versions: 27

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

module Mongoid
  module Errors

    # This error is raised in case of an ambigous association.
    #
    # @example An ambigous association.
    #   class Person
    #     include Mongoid::Document
    #
    #     has_many :invitations, inverse_of: :person
    #     has_many :referred_invitations, class_name: "Invitation", inverse_of: :referred_by
    #   end
    #
    #   class Invitation
    #     include Mongoid::Document
    #
    #     belongs_to :person
    #     belongs_to :referred_by, class_name: "Person"
    #   end
    class AmbiguousRelationship < MongoidError

      # Create the new error.
      #
      # @example Create the error.
      #   AmbiguousRelationship.new(
      #     Person, Drug, :person, [ :drugs, :evil_drugs ]
      #   )
      #
      # @param [ Class ] klass The base class.
      # @param [ Class ] inverse The inverse class.
      # @param [ Symbol ] name The relation name.
      # @param [ Array<Symbol> ] candidates The potential inverses.
      #
      # @since 3.0.0
      def initialize(klass, inverse, name, candidates)
        super(
          compose_message(
            "ambiguous_relationship",
            {
              klass: klass,
              inverse: inverse,
              name: name.inspect,
              candidates: candidates.map(&:inspect).join(", ")
            }
          )
        )
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.3.4 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.11 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.6 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.3.3 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.3.2 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.5 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.10 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.9 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.4 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.3.1 lib/mongoid/errors/ambiguous_relationship.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.3.0 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.3 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.8 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.2 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.1 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.7 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.2.0 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-7.1.6 lib/mongoid/errors/ambiguous_relationship.rb