IronRuby.Builtins.RubyStruct.DefineStruct C# (CSharp) Method

DefineStruct() public static method

public static DefineStruct ( RubyClass owner, string className, string attributeNames ) : RubyClass
owner RubyClass
className string
attributeNames string
return RubyClass
        public static RubyClass/*!*/ DefineStruct(RubyClass/*!*/ owner, string className, string/*!*/[]/*!*/ attributeNames) {
            Assert.NotNullItems(attributeNames);
            
            // MRI: "inherited" event is triggered by DefineClass before the members are defined and the body is evaluated.
            // Any exception thrown by the event will cancel struct initialization.
            RubyClass result = owner.Context.DefineClass(owner, className, owner, new Info(attributeNames));

            AddClassMembers(result, attributeNames);

            return result;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Struct#new
        /// Creates Struct classes with the specified name and members
        /// </summary>
        private static object Create(BlockParam block, RubyClass /*!*/ self, string className, string /*!*/[] /*!*/ attributeNames)
        {
            var result = RubyStruct.DefineStruct(self, className, attributeNames);

            if (block != null)
            {
                return(RubyUtils.EvaluateInModule(result, block, result));
            }

            return(result);
        }
All Usage Examples Of IronRuby.Builtins.RubyStruct::DefineStruct