Created
January 15, 2015 20:52
-
-
Save tdg5/4b5f273b0f5da521cb88 to your computer and use it in GitHub Desktop.
Lexical Scope Is Weird
This file contains hidden or 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 LexicalScope | |
SCOPED_CONSTANT = [:lexical_scope].freeze | |
def scoped_value | |
value = defined?(super) ? super.dup : [] | |
value.concat(SCOPED_CONSTANT) | |
end | |
end | |
module IsWeird | |
SCOPED_CONSTANT = [:is_weird].freeze | |
def scoped_value | |
value = defined?(super) ? super.dup : [] | |
value.concat(SCOPED_CONSTANT) | |
end | |
end | |
class LexicalScopeIsWeird | |
SCOPED_CONTANT = [:lexical_scope_is_awesome!] | |
include LexicalScope | |
include IsWeird | |
end | |
LexicalScopeIsWeird.new.scoped_value | |
# => [:lexical_scope, :is_weird] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment