本文整理汇总了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;
}
示例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;
}
示例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;
}