Class: AE::BasicObject

Inherits:
Object show all
Defined in:
lib/ae/basic_object.rb

Direct Known Subclasses

Assertor, Kernel::Pry

Class Method Summary collapse

Class Method Details

.find_hidden_method(name) ⇒ Object



33
34
35
36
# File 'lib/ae/basic_object.rb', line 33

def self.find_hidden_method(name)
  @hidden_methods ||= {}
  @hidden_methods[name.to_sym] || superclass.find_hidden_method(name)
end

.hide(name) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/ae/basic_object.rb', line 23

def self.hide(name)
  name = name.to_s
  if instance_methods.include?(name) and
    name !~ /^(__|instance_eval|instance_exec)/
    @hidden_methods ||= {}
    @hidden_methods[name.to_sym] = instance_method(name)
    undef_method name
  end
end

.reveal(name) ⇒ Object



40
41
42
43
44
# File 'lib/ae/basic_object.rb', line 40

def self.reveal(name)
  hidden_method = find_hidden_method(name)
  fail "Don't know how to reveal method '#{name}'" unless hidden_method
  define_method(name, hidden_method)
end