зеркало из https://github.com/github/ruby.git
Small improvement in refinements docs
Move general statement about refinements of modules from example to the top of the document. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3c16862c85
Коммит
014a9e0587
|
@ -7,7 +7,7 @@ changes. This can cause unintended side-effects or breakage of programs.
|
||||||
|
|
||||||
Refinements are designed to reduce the impact of monkey patching on other
|
Refinements are designed to reduce the impact of monkey patching on other
|
||||||
users of the monkey-patched class. Refinements provide a way to extend a
|
users of the monkey-patched class. Refinements provide a way to extend a
|
||||||
class locally.
|
class locally. Refinements can modify both classes and modules.
|
||||||
|
|
||||||
Here is a basic refinement:
|
Here is a basic refinement:
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ Here is a basic refinement:
|
||||||
end
|
end
|
||||||
|
|
||||||
First, a class +C+ is defined. Next a refinement for +C+ is created using
|
First, a class +C+ is defined. Next a refinement for +C+ is created using
|
||||||
Module#refine. Refinements can modify both classes and modules.
|
Module#refine.
|
||||||
|
|
||||||
Module#refine creates an anonymous module that contains the changes or
|
Module#refine creates an anonymous module that contains the changes or
|
||||||
refinements to the class (+C+ in the example). +self+ in the refine block is
|
refinements to the class (+C+ in the example). +self+ in the refine block is
|
||||||
|
|
Загрузка…
Ссылка в новой задаче