HasAncestor() публичный Метод

public HasAncestor ( RubyModule module ) : bool
module RubyModule
Результат bool
Пример #1
0
 public static object IsNotSubclassSameOrIncluded(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
 {
     if (module.HasAncestor(self))
     {
         return(true);
     }
     return(self.HasAncestor(module) ? ScriptingRuntimeHelpers.False : null);
 }
Пример #2
0
 public static object IsNotSubclassOrIncluded(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ module)
 {
     if (ReferenceEquals(self, module))
     {
         return(false);
     }
     return(module.HasAncestor(self) ? ScriptingRuntimeHelpers.True : null);
 }
Пример #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));
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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;
        }
Пример #8
0
 public static object IsNotSubclassSameOrIncluded(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
     if (module.HasAncestor(self)) {
         return true;
     }
     return self.HasAncestor(module) ? ScriptingRuntimeHelpers.False : null;
 }
Пример #9
0
 public static object IsSubclassOrIncluded(RubyModule/*!*/ self, [NotNull]RubyModule/*!*/ module) {
     if (ReferenceEquals(self, module)) {
         return false;
     }
     return self.HasAncestor(module) ? ScriptingRuntimeHelpers.True : null;
 }
Пример #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;
        }
Пример #11
0
        public static bool IncludesModule(RubyModule /*!*/ self, [NotNull] RubyModule /*!*/ other)
        {
            RubyUtils.RequireNonClasses(other);

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

            return other != self && self.HasAncestor(other);
        }
Пример #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;
        }