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

ruby-changes:16393

From: marcandre <ko1@a...>
Date: Tue, 22 Jun 2010 13:30:19 +0900 (JST)
Subject: [ruby-changes:16393] Ruby:r28378 (ruby_1_9_2): Backport of r28376:

marcandre	2010-06-22 13:29:59 +0900 (Tue, 22 Jun 2010)

  New Revision: 28378

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

  Log:
    Backport of r28376:
    
    * lib/delegate.rb: Forward #trust, #untrust, #taint and #untaint
      to both the delegator and __getobj__ [ruby-core:26138]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/lib/delegate.rb

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28377)
+++ ruby_1_9_2/ChangeLog	(revision 28378)
@@ -1,3 +1,8 @@
+Tue Jun 22 13:26:47 2010  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* lib/delegate.rb: Forward #trust, #untrust, #taint and #untaint
+	  to both the delegator and __getobj__ [ruby-core:26138]
+
 Tue Jun 22 01:38:23 2010  Masatoshi SEKI  <m_seki@m...>
 
 	* lib/drb/drb.rb: raise DRbConnError instead of ArgumentError if too
Index: ruby_1_9_2/lib/delegate.rb
===================================================================
--- ruby_1_9_2/lib/delegate.rb	(revision 28377)
+++ ruby_1_9_2/lib/delegate.rb	(revision 28378)
@@ -137,7 +137,9 @@
     __setobj__(obj)
   end
 
+  #
   # Handles the magic of delegation through \_\_getobj\_\_.
+  #
   def method_missing(m, *args, &block)
     target = self.__getobj__
     begin
@@ -222,7 +224,9 @@
     raise NotImplementedError, "need to define `__setobj__'"
   end
 
+  #
   # Serialization support for the object returned by \_\_getobj\_\_.
+  #
   def marshal_dump
     ivars = instance_variables.reject {|var| /\A@delegate_/ =~ var}
     [
@@ -231,7 +235,10 @@
       __getobj__
     ]
   end
+
+  #
   # Reinitializes delegation from a serialized object.
+  #
   def marshal_load(data)
     version, vars, values, obj = data
     if version == :__v2__
@@ -250,7 +257,36 @@
   end
   private :initialize_clone, :initialize_dup
 
+  ##
+  # :method: trust
+  # Trust both the object returned by \_\_getobj\_\_ and self.
+  #
+
+  ##
+  # :method: untrust
+  # Untrust both the object returned by \_\_getobj\_\_ and self.
+  #
+
+  ##
+  # :method: taint
+  # Taint both the object returned by \_\_getobj\_\_ and self.
+  #
+
+  ##
+  # :method: untaint
+  # Untaint both the object returned by \_\_getobj\_\_ and self.
+  #
+
+  [:trust, :untrust, :taint, :untaint].each do |method|
+    define_method method do
+      __getobj__.send(method)
+      super()
+    end
+  end
+
+  #
   # Freeze self and target at once.
+  #
   def freeze
     __getobj__.freeze
     super

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

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