Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/blankslate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@
#
class BlankSlate
class << self

# Hide the method named +name+ in the BlankSlate class. Don't
# hide +instance_eval+ or any method beginning with "__".
def hide(name)
methods = instance_methods.map(&:to_sym)
v, $VERBOSE = $VERBOSE, nil
if methods.include?(name.to_sym) and
name !~ /^(__|instance_eval)/
@hidden_methods ||= {}
@hidden_methods[name.to_sym] = instance_method(name)
undef_method name
end
$VERBOSE = v
end

def find_hidden_method(name)
Expand All @@ -42,7 +44,7 @@ def reveal(name)
define_method(name, hidden_method)
end
end

instance_methods.each { |m| hide(m) }
end

Expand Down Expand Up @@ -107,4 +109,4 @@ def append_features(mod)
end
result
end
end
end