lib/mongoid/errors/invalid_relation.rb in mongoid-7.3.5 vs lib/mongoid/errors/invalid_relation.rb in mongoid-7.4.0
- old
+ new
@@ -1,15 +1,12 @@
# frozen_string_literal: true
-# encoding: utf-8
module Mongoid
module Errors
# This error is raised when trying to create an association that conflicts with
# an already defined method.
- #
- # @since 6.0.0
class InvalidRelation < MongoidError
# Create the new error.
#
# @example Create the error.
@@ -40,12 +37,10 @@
#
# @param [ Class ] klass The document class.
# @param [ Symbol ] name The method name.
#
# @return [ Class, Module ] The originating class or module.
- #
- # @since 6.0.0
def origin(klass, name)
klass.instance_method(name).owner
end
# Get the location of the association definition.
@@ -55,11 +50,9 @@
#
# @param [ Class ] klass The document class.
# @param [ Symbol ] name The method name.
#
# @return [ Array<String, Integer> ] The location of the method.
- #
- # @since 6.0.0
def location(klass, name)
@location ||=
(klass.instance_method(name).source_location || [ "Unknown", 0 ])
end
end