HasAncestor() public method

public HasAncestor ( RubyModule module ) : bool
module RubyModule
return bool
Beispiel #1
0
 public static object IsNotSubclassSameOrIncluded(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
 {
     if (module.HasAncestor(self))
     {
         return(true);
     }
     return(self.HasAncestor(module) ? ScriptingRuntimeHelpers.False : null);
 }
Beispiel #2
0
 public static object IsNotSubclassOrIncluded(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
 {
     if (ReferenceEquals(self, module))
     {
         return(false);
     }
     return(module.HasAncestor(self) ? ScriptingRuntimeHelpers.True : null);
 }
Beispiel #3
0
        public static bool IncludesModule(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ other)
        {
            if (other.IsClass)
            {
                throw RubyExceptions.CreateTypeError("wrong argument type Class (expected Module)");
            }

            return(other != self && self.HasAncestor(other));
        }
Beispiel #4
0
        public static UnboundMethod /*!*/ DefineMethod(RubyModule /*!*/ self,
                                                       [DefaultProtocol] string /*!*/ methodName, [NotNull] UnboundMethod /*!*/ method)
        {
            // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
            if (!self.HasAncestor(method.TargetConstraint))
            {
                throw RubyExceptions.CreateTypeError(
                          String.Format("bind argument must be a subclass of {0}", method.TargetConstraint.Name)
                          );
            }

            self.AddDefinedMethod(methodName, method.Info);
            return(method);
        }
Beispiel #5
0
        public static object Comparison(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
        {
            if (ReferenceEquals(self, module))
            {
                return(ScriptingRuntimeHelpers.Int32ToObject(0));
            }

            if (self.HasAncestor(module))
            {
                return(ScriptingRuntimeHelpers.Int32ToObject(-1));
            }

            if (module.HasAncestor(self))
            {
                return(ScriptingRuntimeHelpers.Int32ToObject(1));
            }

            return(null);
        }
Beispiel #6
0
        public static bool IncludesModule(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ other) {
            if (other.IsClass) {
                throw RubyExceptions.CreateTypeError("wrong argument type Class (expected Module)");
            }

            return other != self && self.HasAncestor(other);
        }
Beispiel #7
0
        public static object Comparison(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
            if (ReferenceEquals(self, module)) {
                return ScriptingRuntimeHelpers.Int32ToObject(0);
            }

            if (self.HasAncestor(module)) {
                return ScriptingRuntimeHelpers.Int32ToObject(-1);
            }

            if (module.HasAncestor(self)) {
                return ScriptingRuntimeHelpers.Int32ToObject(1);
            }

            return null;
        }
Beispiel #8
0
 public static object IsNotSubclassSameOrIncluded(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
     if (module.HasAncestor(self)) {
         return true;
     }
     return self.HasAncestor(module) ? ScriptingRuntimeHelpers.False : null;
 }
Beispiel #9
0
 public static object IsSubclassOrIncluded(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
     if (ReferenceEquals(self, module)) {
         return false;
     }
     return self.HasAncestor(module) ? ScriptingRuntimeHelpers.True : null;
 }
Beispiel #10
0
        public static UnboundMethod/*!*/ DefineMethod(RubyContext/*!*/ context, RubyModule/*!*/ self, 
            [DefaultProtocol]string/*!*/ methodName, [NotNull]UnboundMethod/*!*/ method) {

            // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
            if (!self.HasAncestor(method.TargetConstraint)) {
                throw RubyExceptions.CreateTypeError(
                    String.Format("bind argument must be a subclass of {0}", method.TargetConstraint.GetName(context))
                );
            }

            self.AddDefinedMethod(context, methodName, method.Info);
            return method;
        }
Beispiel #11
0
        public static bool IncludesModule(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ other)
        {
            RubyUtils.RequireNonClasses(other);

            return(other != self && self.HasAncestor(other));
        }
Beispiel #12
0
        public static bool IncludesModule(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ other) {
            RubyUtils.RequireNonClasses(other);

            return other != self && self.HasAncestor(other);
        }
Beispiel #13
0
        public static RubyMethod/*!*/ DefineMethod(RubyModule/*!*/ self, 
            [DefaultProtocol]string/*!*/ methodName, [NotNull]RubyMethod/*!*/ method) {

            // MRI 1.8 does the check when the method is called, 1.9 checks it upfront as we do:
            var targetClass = method.GetTargetClass();
            if (!self.HasAncestor(targetClass)) {
                throw RubyExceptions.CreateTypeError(
                    String.Format("bind argument must be a subclass of {0}", targetClass.Name)
                );
            }

            self.AddDefinedMethod(methodName, method.Info);
            return method;
        }