[前][次][番号順一覧][スレッド一覧]

ruby-changes:29694

From: shugo <ko1@a...>
Date: Tue, 2 Jul 2013 17:24:44 +0900 (JST)
Subject: [ruby-changes:29694] shugo:r41746 (trunk): * doc/syntax/refinements.rdoc: add description of Module#using and

shugo	2013-07-02 17:24:26 +0900 (Tue, 02 Jul 2013)

  New Revision: 41746

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41746

  Log:
    * doc/syntax/refinements.rdoc: add description of Module#using and
      refinement inheritance by module inclusion.

  Modified files:
    trunk/ChangeLog
    trunk/doc/syntax/refinements.rdoc

Index: doc/syntax/refinements.rdoc
===================================================================
--- doc/syntax/refinements.rdoc	(revision 41745)
+++ doc/syntax/refinements.rdoc	(revision 41746)
@@ -48,7 +48,7 @@ Activate the refinement with #using: https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L48
 
 == Scope
 
-You may only activate refinements at top-level to the end of the file or in a
+You may activate refinements at top-level to the end of the file or in a
 string passed to Kernel#eval, Kernel#instance_eval or Kernel#module_eval until
 the end of the string.
 
@@ -186,6 +186,25 @@ called: https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L186
 
   p [{1=>2}, {3=>4}].to_json # prints "[{\"1\":2},{\"3\":4}]"
 
+You may also activate refinements in a class or module definition, in which
+case the refinements are activated from the point where using is called to
+the end of the class or module definition:
+
+  # not activated here
+  class Foo
+    # not activated here
+    using M
+    # activated here
+    def foo
+      # activated here
+    end
+    # activated here
+  end
+  # not activated here
+
+Note that the refinements in M are not activated automatically even if the class
+Foo is reopened later.
+
 == Method Lookup
 
 When looking up a method for an instance of class +C+ Ruby checks:
@@ -232,6 +251,12 @@ method lookup. https://github.com/ruby/ruby/blob/trunk/doc/syntax/refinements.rdoc#L251
 
 This behavior may be changed in the future.
 
+== Refinements and module inclusion
+
+Refinements are inherited by module inclusion.  That is, using activates all
+refinements in the ancestors of the specified module.  Refinements in a
+descendant have priority over refinements in an ancestor.
+
 == Further Reading
 
 See http://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec for the
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41745)
+++ ChangeLog	(revision 41746)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul  2 17:23:33 2013  Shugo Maeda  <shugo@r...>
+
+	* doc/syntax/refinements.rdoc: add description of Module#using and
+	  refinement inheritance by module inclusion.
+
 Tue Jul  2 17:22:44 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* internal.h: add EUC-JP and Windows-31J.
@@ -38,8 +43,6 @@ Tue Jul  2 17:22:44 2013  Nobuyoshi Naka https://github.com/ruby/ruby/blob/trunk/ChangeLog#L43
 
 Tue Jul  2 11:14:36 2013  Shota Fukumori  <sorah@c...>
 
-Tue Jul  2 11:14:36 2013  Shota Fukumori  <sorah@c...>
-
 	* lib/mkmf.rb (try_config): Fix to not replace $LDFLAGS with $libs
 	  (1.9.3 behavior) [ruby-core:55752] [Bug #8595]
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]