Skip to content

Instantly share code, notes, and snippets.

@stewart
Created September 30, 2013 23:08
Show Gist options
  • Save stewart/6771611 to your computer and use it in GitHub Desktop.
Save stewart/6771611 to your computer and use it in GitHub Desktop.
Weird scope bug?
class WorkingClass
def call
hidden_method
end
private
def self.hidden_method
"Found me!"
end
def hidden_method
self.class.hidden_method
end
end
class FailingClass
def call
hidden_method
end
class << self
private
def hidden_method
"Found me!"
end
end
private
def hidden_method
self.class.hidden_method
end
end
WorkingClass.new.call
#=> "Found me!"
FailingClass.new.call
#=> private method `hidden_method' called for FailingClass:Class (NoMethodError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment