Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save goyox86/480648 to your computer and use it in GitHub Desktop.
Save goyox86/480648 to your computer and use it in GitHub Desktop.
From a64dc1c80d4cee38e9c967979d2609895f38559a Mon Sep 17 00:00:00 2001
From: Jose Narvaez <[email protected]>
Date: Sun, 18 Jul 2010 14:58:34 -0430
Subject: [PATCH 2/2] Kernel.extend now raises a TypeError, when called on a frozen object
---
kernel/common/kernel.rb | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/kernel/common/kernel.rb b/kernel/common/kernel.rb
index fb897af..7bfcb22 100644
--- a/kernel/common/kernel.rb
+++ b/kernel/common/kernel.rb
@@ -380,6 +380,10 @@ module Kernel
end
def extend(*modules)
+ if self.frozen?
+ raise TypeError, "Cannot modify a frozen object"
+ end
+
modules.reverse_each do |mod|
mod.__send__(:extend_object, self)
mod.__send__(:extended, self)
--
1.7.0.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment