Class
Instance Methods
class.c
View on GitHub
static VALUE
refinement_import_methods(int argc, VALUE *argv, VALUE refinement)
{
}
Imports methods from modules. Unlike Module#include
, Refinement#import_methods
copies methods and adds them into the refinement, so the refinement is activated in the imported methods.
Note that due to method copying, only methods defined in Ruby code can be imported.
module StrUtils def indent(level) ' ' * level + self end end module M refine String do import_methods StrUtils end end using M "foo".indent(3) #=> " foo" module M refine String do import_methods Enumerable # Can't import method which is not defined with Ruby code: Enumerable#drop end end
eval.c
View on GitHub
static VALUE
rb_refinement_refined_class(VALUE module)
{
rb_warn_deprecated_to_remove("3.4", "Refinement#refined_class", "Refinement#target");
return rb_refinement_module_get_refined_class(module);
}
Deprecated; prefer target
.
Return the class refined by the receiver.
eval.c
View on GitHub
VALUE
rb_refinement_module_get_refined_class(VALUE module)
{
ID id_refined_class;
CONST_ID(id_refined_class, "__refined_class__");
return rb_attr_get(module, id_refined_class);
}
Return the class or module refined by the receiver.
module M refine String do end end M.refinements[0].target # => String