From c61f8043997fc5e42b024583575ffcee127d5c3f Mon Sep 17 00:00:00 2001
From: Shugo Maeda <shugo@ruby-lang.org>
Date: Mon, 18 Oct 2010 00:08:52 +0900
Subject: [PATCH 27/51] remove lib/classbox.rb, and moved classbox definition to prelude.rb.

---
 lib/classbox.rb |   77 ------------------------------------------------------
 prelude.rb      |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 77 deletions(-)
 delete mode 100644 lib/classbox.rb

diff --git a/lib/classbox.rb b/lib/classbox.rb
deleted file mode 100644
index d1623f9..0000000
--- a/lib/classbox.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-class Classbox
-  def import_to(binding)
-    return unless @__overlayed_modules__
-    @__overlayed_modules__.each do |klass, modules|
-      modules.each do |mod|
-        overlay_module(klass, mod, binding)
-      end
-    end
-  end
-
-  private
-
-  @@__optimized_methods__ = [
-    :+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=, :>, :>=, :!, :!=,
-    :length, :size, :succ
-  ]
-
-  def refine(klass, &block)
-    @__overlayed_modules__ ||= {}
-    mod = Module.new
-    modules = @__overlayed_modules__[klass] ||= []
-    modules.push(mod)
-    overlay_module(klass, mod, binding(1))
-    mod.singleton_class.send(:define_method, :method_added) do |mid|
-      if @@__optimized_methods__.include?(mid)
-        klass.send(:alias_method, :__original_optimized_method__, mid)
-        klass.send(:define_method, mid) {}
-        klass.send(:alias_method, mid, :__original_optimized_method__)
-        klass.send(:remove_method, :__original_optimized_method__)
-      end
-    end
-    mod.module_eval(&block)
-  end
-end
-
-def classbox(name, &block)
-  klassbox = Classbox.new
-  Object.const_set(name, klassbox)
-  klassbox.module_eval(&block)
-end
-
-def import(klassbox)
-  klassbox.import_to(binding(1))
-end
-
-class Module
-  def import(klassbox)
-    @__imported_classboxes__ ||= {}
-    @__imported_classboxes__[klassbox] = true
-    klassbox.import_to(binding(1))
-  end
-
-  def __opened__(b = binding(1))
-    return unless @__imported_classboxes__
-    @__imported_classboxes__.each_key do |klassbox|
-      klassbox.import_to(b)
-    end
-  end
-end
-
-class Class
-  def __opened__
-    unless @__imported_classboxes__
-      @__imported_classboxes__ =
-        self.superclass.instance_variable_get(:@__imported_classboxes__)
-    end
-    super(binding(1))
-  end
-end
-
-class Classbox
-  def __opened__
-    b = binding(1)
-    import_to(b)
-    super(b)
-  end
-end
diff --git a/prelude.rb b/prelude.rb
index 04bf850..e027534 100644
--- a/prelude.rb
+++ b/prelude.rb
@@ -29,3 +29,81 @@ class Thread
     }
   end
 end
+
+class Classbox
+  def import_to(binding)
+    return unless @__overlayed_modules__
+    @__overlayed_modules__.each do |klass, modules|
+      modules.each do |mod|
+        overlay_module(klass, mod, binding)
+      end
+    end
+  end
+
+  private
+
+  @@__optimized_methods__ = [
+    :+, :-, :*, :/, :%, :==, :===, :<, :<=, :<<, :[], :[]=, :>, :>=, :!, :!=,
+    :length, :size, :succ
+  ]
+
+  def refine(klass, &block)
+    @__overlayed_modules__ ||= {}
+    mod = Module.new
+    modules = @__overlayed_modules__[klass] ||= []
+    modules.push(mod)
+    overlay_module(klass, mod, binding(1))
+    mod.singleton_class.send(:define_method, :method_added) do |mid|
+      if @@__optimized_methods__.include?(mid)
+        klass.send(:alias_method, :__original_optimized_method__, mid)
+        klass.send(:define_method, mid) {}
+        klass.send(:alias_method, mid, :__original_optimized_method__)
+        klass.send(:remove_method, :__original_optimized_method__)
+      end
+    end
+    mod.module_eval(&block)
+  end
+end
+
+def classbox(name, &block)
+  klassbox = Classbox.new
+  Object.const_set(name, klassbox)
+  klassbox.module_eval(&block)
+end
+
+def import(klassbox)
+  klassbox.import_to(binding(1))
+end
+
+class Module
+  def import(klassbox)
+    @__imported_classboxes__ ||= {}
+    @__imported_classboxes__[klassbox] = true
+    klassbox.import_to(binding(1))
+  end
+
+  def __opened__(b = binding(1))
+    return unless @__imported_classboxes__
+    @__imported_classboxes__.each_key do |klassbox|
+      klassbox.import_to(b)
+    end
+  end
+end
+
+class Class
+  def __opened__
+    unless @__imported_classboxes__
+      @__imported_classboxes__ =
+        self.superclass.instance_variable_get(:@__imported_classboxes__)
+    end
+    super(binding(1))
+  end
+end
+
+class Classbox
+  def __opened__
+    b = binding(1)
+    import_to(b)
+    super(b)
+  end
+end
-- 
1.7.0.4

