本文整理了Java中org.jruby.RubyModule.yieldRefineBlock
方法的一些代码示例,展示了RubyModule.yieldRefineBlock
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.yieldRefineBlock
方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称:RubyModule
方法名:yieldRefineBlock
暂无
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "refine", required = 1, reads = SCOPE)
public IRubyObject refine(ThreadContext context, IRubyObject target, Block block) {
if (!block.isGiven()) throw context.runtime.newArgumentError("no block given");
if (block.isEscaped()) throw context.runtime.newArgumentError("can't pass a Proc as a block to Module#refine");
if (!(target instanceof RubyModule)) throw context.runtime.newTypeError("wrong argument type " + target.getType() + "(expected Class or Module)");
if (refinements == Collections.EMPTY_MAP) refinements = new IdentityHashMap<>();
if (activatedRefinements == Collections.EMPTY_MAP) activatedRefinements = new IdentityHashMap<>();
RubyModule moduleToRefine = (RubyModule) target;
RubyModule refinement = refinements.get(moduleToRefine);
if (refinement == null) {
refinement = createNewRefinedModule(context, moduleToRefine);
// Add it to the activated chain of other refinements already added to this class we are refining
addActivatedRefinement(context, moduleToRefine, refinement);
}
// Executes the block supplied with the defined method definitions using the refinment as it's module.
yieldRefineBlock(context, refinement, block);
return refinement;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "refine", required = 1, reads = SCOPE)
public IRubyObject refine(ThreadContext context, IRubyObject target, Block block) {
if (!block.isGiven()) throw context.runtime.newArgumentError("no block given");
if (block.isEscaped()) throw context.runtime.newArgumentError("can't pass a Proc as a block to Module#refine");
if (!(target instanceof RubyModule)) throw context.runtime.newTypeError("wrong argument type " + target.getType() + "(expected Class or Module)");
if (refinements == Collections.EMPTY_MAP) refinements = new IdentityHashMap<>();
if (activatedRefinements == Collections.EMPTY_MAP) activatedRefinements = new IdentityHashMap<>();
RubyModule moduleToRefine = (RubyModule) target;
RubyModule refinement = refinements.get(moduleToRefine);
if (refinement == null) {
refinement = createNewRefinedModule(context, moduleToRefine);
// Add it to the activated chain of other refinements already added to this class we are refining
addActivatedRefinement(context, moduleToRefine, refinement);
}
// Executes the block supplied with the defined method definitions using the refinment as it's module.
yieldRefineBlock(context, refinement, block);
return refinement;
}
内容来源于网络,如有侵权,请联系作者删除!