Refinement
is a class of the self
(current context) inside refine
statement. It allows to import methods from other modules, see import_methods
.
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) module M refine String do import_methods Enumerable end end
Also aliased as: import_methods
SourceVALUE 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3