Sha256: 5398c6a513730a69936108ce4d5d5d48e44b438a482d909af3cb8202f7ab5809

Contents?: true

Size: 1.38 KB

Versions: 67

Compression:

Stored size: 1.38 KB

Contents

# encoding: utf-8
module Mongoid
  module Errors

    # This error is raised in case of an ambigous relationship.
    #
    # @example An ambigous relationship.
    #   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

67 entries across 64 versions & 7 rubygems

Version Path
mongoid-5.4.1 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.4.0 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.2.1 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.2.0 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.2.0.rc0 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.6 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.5 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.4 lib/mongoid/errors/ambiguous_relationship.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-5.1.3/lib/mongoid/errors/ambiguous_relationship.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.3 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.2 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.1 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.1.0 lib/mongoid/errors/ambiguous_relationship.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongoid-5.0.2/lib/mongoid/errors/ambiguous_relationship.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.2/lib/mongoid/errors/ambiguous_relationship.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.0.2 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.0.1 lib/mongoid/errors/ambiguous_relationship.rb
mongoid-5.0.0 lib/mongoid/errors/ambiguous_relationship.rb