Class BlankSlate
In: vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb
Parent: Object

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).

Methods

Public Class methods

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb, line 31
31:     def find_hidden_method(name)
32:       @hidden_methods ||= {}
33:       @hidden_methods[name] || superclass.find_hidden_method(name)
34:     end

Hide the method named name in the BlankSlate class. Don‘t hide instance_eval or any method beginning with "__".

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/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.

[Source]

    # File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/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

[Validate]