diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-03-08 16:54:57 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-03-08 16:54:57 +0000 |
commit | 47ffc04621c4ce5cbf491091d3680e8e34e674b7 (patch) | |
tree | 7d707c0945188ccc3d4ccbe46160bf084feeefd3 /activesupport/lib/active_support/vendor/builder/blankslate.rb | |
parent | 519e7e5e1236dfb75a7d759e0a143bc9e0e47385 (diff) | |
download | rails-47ffc04621c4ce5cbf491091d3680e8e34e674b7.tar.gz rails-47ffc04621c4ce5cbf491091d3680e8e34e674b7.tar.bz2 rails-47ffc04621c4ce5cbf491091d3680e8e34e674b7.zip |
move vendor inside lib so that rake freeze_edge works
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3818 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/vendor/builder/blankslate.rb')
-rw-r--r-- | activesupport/lib/active_support/vendor/builder/blankslate.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/vendor/builder/blankslate.rb b/activesupport/lib/active_support/vendor/builder/blankslate.rb new file mode 100644 index 0000000000..1408c872cc --- /dev/null +++ b/activesupport/lib/active_support/vendor/builder/blankslate.rb @@ -0,0 +1,53 @@ +#!/usr/bin/env ruby +#-- +# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +module Builder #:nodoc: + + # BlankSlate provides an abstract base class with no predefined + # methods (except for <tt>\_\_send__</tt> and <tt>\_\_id__</tt>). + # BlankSlate is useful as a base class when writing classes that + # depend upon <tt>method_missing</tt> (e.g. dynamic proxies). + class BlankSlate #:nodoc: + class << self + def hide(name) + undef_method name if + instance_methods.include?(name.to_s) and + name !~ /^(__|instance_eval)/ + end + end + + instance_methods.each { |m| hide(m) } + end +end + +# Since Ruby is very dynamic, methods added to the ancestors of +# BlankSlate <em>after BlankSlate is defined</em> will show up in the +# list of available BlankSlate methods. We handle this by defining a hook in the Object and Kernel classes that will hide any defined +module Kernel #:nodoc: + class << self + alias_method :blank_slate_method_added, :method_added + def method_added(name) + blank_slate_method_added(name) + return if self != Kernel + Builder::BlankSlate.hide(name) + end + end +end + +class Object #:nodoc: + class << self + alias_method :blank_slate_method_added, :method_added + def method_added(name) + blank_slate_method_added(name) + return if self != Object + Builder::BlankSlate.hide(name) + end + end +end |