class BlankSlate
BlankSlate
provides an abstract base class with no predefined methods (except for _\send_
and _\id_
). BlankSlate
is useful as a base class when writing classes that depend upon method_missing
(e.g. dynamic proxies).
Private Class Methods
hide(name)
click to toggle source
Hide the method named name
in the BlankSlate
class. Don't hide instance_eval
or any method beginning with “__”.
# File lib/blankslate.rb 47 def hide(name) 48 warn_level = $VERBOSE 49 $VERBOSE = nil 50 if instance_methods.include?(name._blankslate_as_name) && 51 name !~ /^(__|instance_eval$)/ 52 @hidden_methods ||= {} 53 @hidden_methods[name.to_sym] = instance_method(name) 54 undef_method name 55 end 56 ensure 57 $VERBOSE = warn_level 58 end
reveal(name)
click to toggle source
Redefine a previously hidden method so that it may be called on a blank slate object.
# File lib/blankslate.rb 67 def reveal(name) 68 hidden_method = find_hidden_method(name) 69 fail "Don't know how to reveal method '#{name}'" unless hidden_method 70 define_method(name, hidden_method) 71 end