当前位置: 首页>>代码示例>>Java>>正文


Java RubyModule.KindOf方法代码示例

本文整理汇总了Java中org.jruby.RubyModule.KindOf方法的典型用法代码示例。如果您正苦于以下问题:Java RubyModule.KindOf方法的具体用法?Java RubyModule.KindOf怎么用?Java RubyModule.KindOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jruby.RubyModule的用法示例。


在下文中一共展示了RubyModule.KindOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: define

import org.jruby.RubyModule; //导入方法依赖的package包/类
/**
 * This method registers the class with the given runtime.
 *
 * @param runtime an instance of the Ruby runtime
 * @return        a RubyClass object with metadata about the registered class
 */
public static RubyClass define(Ruby runtime) {
    RubyClass result = runtime.defineClass("Schema",runtime.getObject(), ALLOCATOR);

    result.kindOf = new RubyModule.KindOf() {
        public boolean isKindOf(IRubyObject obj, RubyModule type) {
            return obj instanceof RubySchema;
        }
    };

    result.includeModule(runtime.getEnumerable());

    result.defineAnnotatedMethods(RubySchema.class);

    return result;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:22,代码来源:RubySchema.java

示例2: define

import org.jruby.RubyModule; //导入方法依赖的package包/类
/**
 * This method registers the class with the given runtime. It is not necessary to do this here,
 * but it is simpler to associate the methods necessary to register the class with the class
 * itself, so on the Library side it is possible to just specify "RubyDataBag.define(runtime)".
 *
 * @param runtime an instance of the Ruby runtime
 * @return        a RubyClass object with metadata about the registered class
 */
public static RubyClass define(Ruby runtime) {
    // This generates the class object associated with DataBag, and registers it with the
    // runtime. The RubyClass object has all the metadata associated with a Class itself.
    RubyClass result = runtime.defineClass("DataBag", runtime.getObject(), ALLOCATOR);

    // This registers a method which can be used to know whether a module is an
    // instance of the class.
    result.kindOf = new RubyModule.KindOf() {
        public boolean isKindOf(IRubyObject obj, RubyModule type) {
            return obj instanceof RubyDataBag;
        }
    };

    // This includes the Enumerable module that we specified.
    result.includeModule(runtime.getEnumerable());

    // This method actually reads the annotations we placed and registers
    // all of the methods.
    result.defineAnnotatedMethods(RubyDataBag.class);

    // This returns the RubyClass object with all the new metadata.
    return result;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:32,代码来源:RubyDataBag.java

示例3: define

import org.jruby.RubyModule; //导入方法依赖的package包/类
/**
 * Registers the DataByteArray class with the Ruby runtime.
 *
 * @param runtime an instance of the Ruby runtime
 * @return a RubyClass object with metadata about the registered class
 */
public static RubyClass define(Ruby runtime) {
    RubyClass result = runtime.defineClass("DataByteArray", runtime.getObject(), ALLOCATOR);

    result.kindOf = new RubyModule.KindOf() {
        public boolean isKindOf(IRubyObject obj, RubyModule type) {
            return obj instanceof RubyDataByteArray;
        }
    };

    result.defineAnnotatedMethods(RubyDataByteArray.class);

    return result;
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:20,代码来源:RubyDataByteArray.java


注:本文中的org.jruby.RubyModule.KindOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。