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).
Hide the method named name in the BlankSlate class. Don’t hide instance_eval or any method beginning with “__”.
# File lib/blankslate.rb, line 22 22: def hide(name) 23: if instance_methods.include?(name.to_s) and 24: name !~ /^(__|instance_eval)/ 25: @hidden_methods ||= {} 26: @hidden_methods[name.to_sym] = instance_method(name) 27: undef_method name 28: end 29: end
Redefine a previously hidden method so that it may be called on a blank slate object.
# File lib/blankslate.rb, line 38 38: def reveal(name) 39: bound_method = nil 40: unbound_method = find_hidden_method(name) 41: fail "Don't know how to reveal method '#{name}'" unless unbound_method 42: define_method(name) do |*args| 43: bound_method ||= unbound_method.bind(self) 44: bound_method.call(*args) 45: end 46: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.