Sha256: d17ace7f17434b5fb3c94b0b3f17ff0235f2303b3fae9f305284bf4dd8cf689c
Contents?: true
Size: 1.11 KB
Versions: 24
Compression:
Stored size: 1.11 KB
Contents
# <!-- rdoc-file=class.c --> # Refinement is a class of the `self` (current context) inside `refine` # statement. It allows to import methods from other modules, see # #import_methods. # class Refinement < Module private # <!-- # rdoc-file=class.c # - import_methods(module, ...) -> self # --> # 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 # def import_methods: (*Module) -> self end
Version data entries
24 entries across 24 versions & 2 rubygems