Created
September 28, 2010 01:25
-
-
Save myobie/600227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Scope | |
module ScopeMethods | |
def helpers(&block) | |
instance_eval(&block) | |
end | |
end | |
def scope(path, &block) | |
(@path_parts ||= []) << path | |
context = eval('self', block.binding).dup | |
context.extend ScopeMethods | |
context.instance_eval(&block) | |
@path_parts.pop | |
end | |
end | |
include Scope | |
scope "something" do | |
helpers do | |
def foo | |
"bar" | |
end | |
end | |
puts foo # => should work | |
end | |
puts foo # => should error | |
Let me know if your tests pass with that
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to refactor the
scope()
method to the following: