Skip to content

Instantly share code, notes, and snippets.

@myobie
Created September 28, 2010 01:25
Show Gist options
  • Save myobie/600227 to your computer and use it in GitHub Desktop.
Save myobie/600227 to your computer and use it in GitHub Desktop.
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
@banister
Copy link

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